Copy link to clipboard
Copied
Whenever I run a script file, it seems that the working directory is the same directory that the script is located at. However, suppose I want to change the current working directory at run time, including directories which may be located on different drives which may include spaces in their name. How would I do this in ExtendScript?
The reason that I ask is because I have ExtendScript running other files that expect to be run from specific directories, and I need to change the current working directory before I run them.
Copy link to clipboard
Copied
I'm not clear what you are asking. You should not have any issues by pointing to other folders using their URIs or invoking extra file dialogs. The only thing of concern are potential limitations due to user permissions and other security stuff.
Mylenium
Copy link to clipboard
Copied
Here's an example of what I mean. If I have a Python script that is located in a different directory than the .jsx script and I call it from the .jsx script with something like:
Copy link to clipboard
Copied
instead of executing the python script directly, you could execute a bat file (or on Mac a shell script) that first changes to that directory and then executes the script.
Copy link to clipboard
Copied
Sounds convoluted, TBH. Have you considered simply setting system variables/ Py variables? My knowledge of Python is certainly limited outside specific contexts, but I seem to vaguely remeber that it allows to define some custom global variables that it looks up every time the engine is invoked. Perhaps that might simplify the process. Other than that it seems to me you may need to mutually implement code that scans for whether the scripts actually exist in the respective folders and create some kind of temporary file containing a text string containing the path or something like that....
Mylenium
Copy link to clipboard
Copied
I managed to get around it by passing the directory from Extendscript as an argument to the Python script and then changing the directory directly in Python. Not ideal, but it works.