Copy link to clipboard
Copied
Can a script get the active document parent directory name?
For instance, the script gets the directory name Summer Flowers when processing the jpg images in this directory.
|- Summer Flowers
|-- flower1.jpg
|-- flower2.jpg
|-- flower3.jpg
You could use:-
alert(decodeURI(app.activeDocument.path.name));
Copy link to clipboard
Copied
This gets the name of the name of the parent folder of the active document. Also inserts the value %20 in the alert dialog displaying Summer%20Flowers rather than Summer Flowers. Can this %20 value be removed from the alert dialog?
var doc = app.activeDocument;
var parentFolder = doc.path.name
alert(parentFolder)
Copy link to clipboard
Copied
ok found it. This replaces the %20 value. replace(/%20/g," ")
var doc = app.activeDocument;
var parentFolder = doc.path.name
alert(parentFolder.replace(/%20/g," "))
Copy link to clipboard
Copied
You could use:-
alert(decodeURI(app.activeDocument.path.name));
Copy link to clipboard
Copied
Thank you this works!
Is it possible to go up one more level to the Seasonal Flowers directory from the app.activeDocument?
I try using relative path to the Seasonal Flowers directory, but it did not work.
|- Seasonal Flowers
|-- Summer Flowers
|---flower1.jpg
|---flower2.jpg
|---flower3.jpg
Copy link to clipboard
Copied
Examples...
alert(decodeURI(app.activeDocument.path.name));
alert(decodeURI(app.activeDocument.path.parent.name));
alert(decodeURI(app.activeDocument.path.parent.parent.name));
Copy link to clipboard
Copied
Thank you SuperMerlin! Super useful!