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

How to get a file path?

Explorer ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Suppose a file is open, it is current, so how to get this file unique path by JavaScript without the file name?

TOPICS
Actions and scripting

Views

6.3K

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 guidelines

correct answers 1 Correct answer

Community Expert , Aug 08, 2017 Aug 08, 2017

There are several kinds of notation. This is a URI notation. E.g. for adressing and opening files.

If you need C:\ you can get this by

alert("get path of activeDoc: "+(activeDocument.path.fsName));

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hi andyf65867865​,

you can read the properties of document or activeDocument in ESTK

File properties you can get by switching to Core JavaScript Classes in ESTK

In this case for a file which is already saved and opened in PS

alert("get path of activeDoc: "+activeDocument.path);

Have fun

Votes

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 guidelines
Explorer ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

suppose a file is in the c:/folder1
then your script gives a result
/c/folder1

which is slightly different... why is it?

Votes

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 guidelines
Guide ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

This might be more like you are after...

#target photoshop;

try{

    alert("get path of activeDoc: "+activeDocument.path.fsName); 

    }catch(e){alert("This file has not yet been saved!");}

Votes

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 guidelines
Community Expert ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

SuperMerlin​

Two souls, one thought.

Votes

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 guidelines
Guide ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

LATEST

Votes

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 guidelines
Community Expert ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

There are several kinds of notation. This is a URI notation. E.g. for adressing and opening files.

If you need C:\ you can get this by

alert("get path of activeDoc: "+(activeDocument.path.fsName));

Votes

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 guidelines