I would like to create a set of scripts that will be placed together in a folder that are used in a few machines. Due to the fact that they would have different settings, I would like to create a “settings” script file that stores the variables that differ from each set. Hence, the only file that I need to change when I put those files into different machines is the “settings” script file. Those scripts would be called by osascript when needed and load the “settings” file by “load script”.
The problem is, I would liek to get the path of the running script. Unfortunately, “path to me” give me the path of osascript instead of the scripts themselves. How to get the folder or path of the running script; therefore, I can call load?
Thanks a ton in advance!
“me”, in an expression as “path to me” is allways the “folk who is running the script”, that is because you get the path to osascript.
You could store the variables in a common place to any machine, such as the preferences folder. Eg:
I’ve been working with “path to me” a few days ago and what I discovered is that it will return the path to Script Editor if you’re executing the script from SE, but if you save the script as an application it will then return the path to the app.
To get the folder you’d have to remove the “YOUR_APP.app” part. I’ve written a handler (using Applescript’s text item delimiters) that does it, but I’m not at home now. If you think it might help I’ll post it later.
I think there is also something with “enclosing folder” or “containing folder” or something like that, but I looked around and couldn’t find anything.
Good luck with it and I’ll check back later (maybe monday though)
You can use:
the container of (the path to me)
And that will return the folder that your script is in. Or, as mentioned above, the path to the Script Editor folder if your running it from the script editor.
Hope this helps,
What I really want is the folder of the script. That would mean I have to use a fixed path somehow.