I want to get the absolute folder path of current running Extendscript.
i.e __DIR__
in php (or) __dirname
in nodejs. Equivalent in Extendscript.
I want to get the absolute folder path of current running Extendscript.
i.e __DIR__
in php (or) __dirname
in nodejs. Equivalent in Extendscript.
Found it myself, it is $.fileName
For the folder name, it is (new File($.fileName)).parent
$.fileName
returns the absolute path to the current executing script, not the opened file (e.g. the .ai file you're editing in Illustrator). –
Darrow $.fileName
works fine in the context of "pure" scripting execution, it may return garbage (like a random integer) if you evaluate in the context of an HTML Panel in some Adobe applications such as Photoshop. In that case, if you need to get the absolute path of a JSX, you may want to use CSInterface.prototype.getSystemPath()
–
Doty I wrote an article about this you may find helpful, :)
essentially:
var myPath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');
var myScriptPath = (File(app.activeScript.fullName).parent.fsName).toString().replace(/\\/g, '/');
alert('Document path is: ' + myPath + ' , and script path is: ' + myScriptPath);
mim,
File($.fileName).path;
Seems to do the job nowadays
If you need to reference files relative to the active document you can use app.activeDocument.filePath
.
app.activeDocument
≠ app.activeScript
–
Rensselaerite app.activeScript.parent
should do the trick - note that if you use a windows file link, you get the actual script location, not the one of the .lnk-file.
© 2022 - 2024 — McMap. All rights reserved.
/c/some%20folde%20with%spaces/some/folder
-but the script likes this. – Torquemada