Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to call a variable file path in javascript

Guest
Nov 15, 2013 Nov 15, 2013

Hi,

My objective is to capture a file path on mac and windows. However, this file path gets changed with various users.

For example the path is:

c:\user\username\AppData\Local\Temp\myfolder------> this is for windows machine

/users/username/Library/Application Support/tempfolder/Temporary Files/-------> this is for mac machine

As you can see, the path will be same for all the machines. Only the difference will be in searching the user and username at the start of file path. Rest folders will remain same on all the machines.

Is there any grep pattern through which I can call this complete path in a variable for all the users.

Any help will be appreciated.

Regards,

Abhi

TOPICS
Scripting
5.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 16, 2013 Nov 16, 2013

Hi,

You are able to check OS:

var currOS = $.os;

regarding to value of this string you can switch to various paths

Jarek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2013 Nov 16, 2013

Thanks Jerek!!!

Regards,

Abhishek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 16, 2013 Nov 16, 2013

You can do this like so (independently of the platform and user name):

var tempFolder = Folder.temp;

var myDocumentsFolder = Folder.myDocuments;

var desktopFolder = Folder.desktop;

You can get the full list of all available folders on page 56 ("Folder class properties" section) in "JavaScript Tools Guide"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2013 Nov 16, 2013

Thanks for your reply!

I will check the points as you mentioned.

Regards,

Abhishek

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 19, 2013 Nov 19, 2013
LATEST

If you want default user path you can simply use "~" character.

 

"~/AppData/Local/Temp/myfolder" same as  "c:\user\username\AppData\Local\Temp\myfolder"

"~/Library/Application Support/tempfolder/Temporary Files/" is same  as "/users/username/Library/Application Support/tempfolder/Temporary Files/"

"~" is interpreted as path to default user directory on Mac and Windows both.

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