Highlighted

[Javascript] Grabbing local URL from another file?

New Here ,
Sep 01, 2020

Copy link to clipboard

Copied

Hello, I was wondering if it would be possible to grab the current parent folder path without the folder path listed within the Javascript file.

 

For example, I have about 63 shortcut files that are located within a folder in location A.

C:\Users\USERNAME\OneDrive\Backup\Shortcuts\TEMPLATES

 

Within each script (indesign script files are within the scripts panel appdata file location) lists a path for each shortcut in location A:

var templateFile = new File("C:/Users/USERNAME/OneDrive/Backup/Shortcuts/TEMPLATES/template01.lnk");

var template = app.open(templateFile);

 

This being said, I think it would be super tedious to have to go through over 60+ files to change each file path in case I have to switch computers or have someone else use these files - thus resulting in a completely new file path.

 

Is there any way of grabbing the local URL of the parent folder path of the shortcut without having to have it manually typed out like it currently is on each file? Maybe having the local URL of the parent folder path listed in a separate file?

 

The final product would preferably look something like this:

var templateFile = new File(TEMPLATE_PATH + "template01.lnk");

var template = app.open(templateFile);

 

Thank you!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi,

but my sample already includes the current user folder.

Folder("~/")

From that on you easily should get on to OneDrive with:

var templateFolder = 
Folder("~/"+"OneDrive/Backup/Shortcuts/TEMPLATES/");
var templateFile = 
File( templateFolder + "template01.lnk" );

 

Wouldn't that work for you?

 

Always test if it exists like that:

Folder("~/"+"OneDrive").exists

Should return true…

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Scripting

Views

58

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

[Javascript] Grabbing local URL from another file?

New Here ,
Sep 01, 2020

Copy link to clipboard

Copied

Hello, I was wondering if it would be possible to grab the current parent folder path without the folder path listed within the Javascript file.

 

For example, I have about 63 shortcut files that are located within a folder in location A.

C:\Users\USERNAME\OneDrive\Backup\Shortcuts\TEMPLATES

 

Within each script (indesign script files are within the scripts panel appdata file location) lists a path for each shortcut in location A:

var templateFile = new File("C:/Users/USERNAME/OneDrive/Backup/Shortcuts/TEMPLATES/template01.lnk");

var template = app.open(templateFile);

 

This being said, I think it would be super tedious to have to go through over 60+ files to change each file path in case I have to switch computers or have someone else use these files - thus resulting in a completely new file path.

 

Is there any way of grabbing the local URL of the parent folder path of the shortcut without having to have it manually typed out like it currently is on each file? Maybe having the local URL of the parent folder path listed in a separate file?

 

The final product would preferably look something like this:

var templateFile = new File(TEMPLATE_PATH + "template01.lnk");

var template = app.open(templateFile);

 

Thank you!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi,

but my sample already includes the current user folder.

Folder("~/")

From that on you easily should get on to OneDrive with:

var templateFolder = 
Folder("~/"+"OneDrive/Backup/Shortcuts/TEMPLATES/");
var templateFile = 
File( templateFolder + "template01.lnk" );

 

Wouldn't that work for you?

 

Always test if it exists like that:

Folder("~/"+"OneDrive").exists

Should return true…

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Scripting

Views

59

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
Sep 01, 2020 0
Adobe Community Professional ,
Sep 01, 2020

Copy link to clipboard

Copied

Hi,

I wonder what the "current parent folder path" should be?

The folder that comes with the current user?

 

For example this would return ~/AppData/Roaming on Windows 10:

Folder.userData

 

Regards,
Uwe Laubender

( ACP )

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...
Sep 01, 2020 0
New Here ,
Sep 01, 2020

Copy link to clipboard

Copied

That would be helpful if I'm trying to use part of the AppData/Roaming url to grab the script location, but I'm trying to grab the location of the shortcut files. Currently the parent folder path for the shortcut files are stored within OneDrive. That location may change, depending on the situation. I should also mention that with each template file, there is a script file to match. This was done so that way then I didn't need to go digging through folders to find each template file, where I could just open the file directly without dealing with a dialog box either. Now there's the issue of having individual script files with slightly different filepaths. 

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...
Sep 01, 2020 0
Adobe Community Professional ,
Sep 01, 2020

Copy link to clipboard

Copied

Hi,

but my sample already includes the current user folder.

Folder("~/")

From that on you easily should get on to OneDrive with:

var templateFolder = 
Folder("~/"+"OneDrive/Backup/Shortcuts/TEMPLATES/");
var templateFile = 
File( templateFolder + "template01.lnk" );

 

Wouldn't that work for you?

 

Always test if it exists like that:

Folder("~/"+"OneDrive").exists

Should return true…

 

Regards,
Uwe Laubender

( ACP )

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...
Sep 01, 2020 0
S_3_R_0 LATEST
New Here ,
Sep 01, 2020

Copy link to clipboard

Copied

Not exactly what I was looking for, but this work. Thank you for your help!

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...
Sep 01, 2020 0