Hello Everybody,
I am desperately trying to get the path of the script inside the script itself.
The best solution I could find for now is to get the application path with app.path and add the extra string "/Presets/Scripts" manually. Nevertheless, this means I now have to detect which OS I am running the script from in order to add the right piece of string. This seems far from ideal. If anybody wants to understand why I need that, it is because I am writing an ini file in the same place as the script to store the latest settings.
Thanks you for reading.
Getting the path of the current script
Getting the path of the current script
Does… '$.fileName' not work for this? I can't check as I think the property came about in CS3…
Getting the path of the current script
A new silly question. Is there some kind of environment variable which returns your scripts folder path.
For example on a Mac it would be something like "/Applications/Photoshop/Presets/Scripts".
Thanks.
For example on a Mac it would be something like "/Applications/Photoshop/Presets/Scripts".
Thanks.
Getting the path of the current script
If you get yourself the Javascript Tools Guides you will find under the 'folder' object of 'file system access' there are several properties that are folder shortcuts listed as this is for all apps of the suite and both OS's there is NO one hit answer for each app's scripting folder but you could possibly use these to make a shorter more flexible path…
Getting the path of the current script
Yes, none seems to hit the script folder directly, nevertheless this folder object is good to know. I will probably have to add the missing bit after detecting which OS I am running under.
Thanks.
Thanks.
Getting the path of the current script
Asterokid wrote:Is there some kind of environment variable which returns your scripts folder path.
Adobe has a z-string for that...
Adobe has a z-string for that...
Code: Select all
var scriptsPath = app.path + "/" + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");[code]
That should point to the scripts folder on any OS and any language version. Although it's not clear if Presets/Scripts is localized.
Getting the path of the current script
It works on Mac but I am not convince it's going to work on Windows because of these "/" we are adding to the string.
I'll try when I get home.
Thanks.
I'll try when I get home.
Thanks.
Getting the path of the current script
It works with Windows.
In extendscript there are two ways to build a path string for Windows. One way is to use backward slashes 'c:\\testFolder'. Note that the backward slash needs to be escaped with another back slash. You can also use '/c/testFolder'. Both string create a path to the same folder. Most of us seem to use the later method. For example '~/desktop' works on both Mac and Windows so there is no need to create two strings one for each OS.
In extendscript there are two ways to build a path string for Windows. One way is to use backward slashes 'c:\\testFolder'. Note that the backward slash needs to be escaped with another back slash. You can also use '/c/testFolder'. Both string create a path to the same folder. Most of us seem to use the later method. For example '~/desktop' works on both Mac and Windows so there is no need to create two strings one for each OS.
Getting the path of the current script
Indeed it works with Windows. That's great. Thanks a lot for your advices.