Highlighted

get file path of executing javascript

Community Beginner ,
Aug 23, 2020

Copy link to clipboard

Copied

I am executing a javascript file and from within this file I want to execute other files. 

 

I can use $.evalFile(file) if I fully qualify the file to run. i.e. $.evalFile("C:/temp/name.js");  But I want to run the file based on the location of the currently running javascript.  I cannot seem to find a way to get access to the DOM object to determine anything.  I seem to have access to the app object but I cannot find any documentation on this object to determine if it might have a method I can use. 

 

I found app.activeDocument. Do thing the following:

 

docRef = app.activeDocument;

 

So I have access to the document object as well but I still need to find the property on one of these two which will give me the extension path so I do not have to hardcode it into my function. 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following, it shall give the path of the executing script

$.fileName

-Manan

Topics

Actions and scripting, How to

Views

44

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

get file path of executing javascript

Community Beginner ,
Aug 23, 2020

Copy link to clipboard

Copied

I am executing a javascript file and from within this file I want to execute other files. 

 

I can use $.evalFile(file) if I fully qualify the file to run. i.e. $.evalFile("C:/temp/name.js");  But I want to run the file based on the location of the currently running javascript.  I cannot seem to find a way to get access to the DOM object to determine anything.  I seem to have access to the app object but I cannot find any documentation on this object to determine if it might have a method I can use. 

 

I found app.activeDocument. Do thing the following:

 

docRef = app.activeDocument;

 

So I have access to the document object as well but I still need to find the property on one of these two which will give me the extension path so I do not have to hardcode it into my function. 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following, it shall give the path of the executing script

$.fileName

-Manan

Topics

Actions and scripting, How to

Views

45

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 23, 2020

Copy link to clipboard

Copied

ignore this reply. I have added it into the original post.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Aug 23, 2020

Copy link to clipboard

Copied

Try the following, it shall give the path of the executing script

$.fileName

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...