Skip to main content
Inspiring
August 8, 2017
Answered

How to get a file path?

  • August 8, 2017
  • 1 reply
  • 7368 views

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

This topic has been closed for replies.
Correct answer pixxxelschubser

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));

1 reply

pixxxelschubser
Community Expert
Community Expert
August 8, 2017

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

Inspiring
August 8, 2017

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

which is slightly different... why is it?

SuperMerlin
Inspiring
August 8, 2017

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!");}