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

Active document parent directory anme

Engaged ,
May 29, 2018 May 29, 2018

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

TOPICS
Actions and scripting
3.5K
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

correct answers 1 Correct answer

Guide , May 30, 2018 May 30, 2018

You could use:-

alert(decodeURI(app.activeDocument.path.name));

Translate
Adobe
Engaged ,
May 29, 2018 May 29, 2018

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)

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
Engaged ,
May 29, 2018 May 29, 2018

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," "))

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
Guide ,
May 30, 2018 May 30, 2018

You could use:-

alert(decodeURI(app.activeDocument.path.name));

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
Engaged ,
May 30, 2018 May 30, 2018

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

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
Guide ,
May 30, 2018 May 30, 2018

Examples...

alert(decodeURI(app.activeDocument.path.name));

alert(decodeURI(app.activeDocument.path.parent.name));

alert(decodeURI(app.activeDocument.path.parent.parent.name));

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
Engaged ,
May 30, 2018 May 30, 2018
LATEST

Thank you SuperMerlin! Super useful!

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