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

Parent Directory Only

Participant ,
Feb 19, 2016 Feb 19, 2016

Have a quick question that I can not find help with in the ESTB.  I am trying to get the parent Folder name of a file without the full directory. 

Desktop

Folder - Need this Name

File

I have tried ($.SourceFile).parent;  But it only returns "Desktop" not the Folder name.

TOPICS
Scripting
741
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

Community Expert , Feb 20, 2016 Feb 20, 2016

Hi jeremy0013‌,

same question here: what is $.SourceFile ?

Independently of

var file = File('~/Testfolder_1/Testfolder_2/check.jpg'); // replace with the path to your own file

alert(file.parent.name); // get: Testfolder_2

alert(file.parent.parent.name); // get: Testfolder_1

Have fun

Translate
Adobe
Community Expert ,
Feb 19, 2016 Feb 19, 2016

in your scenario, all you have to do is get a reference to the File object then call it's parent property.

what's $.SourceFile?

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
Community Expert ,
Feb 20, 2016 Feb 20, 2016

Hi jeremy0013‌,

same question here: what is $.SourceFile ?

Independently of

var file = File('~/Testfolder_1/Testfolder_2/check.jpg'); // replace with the path to your own file

alert(file.parent.name); // get: Testfolder_2

alert(file.parent.parent.name); // get: Testfolder_1

Have fun

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
Participant ,
Feb 24, 2016 Feb 24, 2016
LATEST

Got this to work.  What I am trying to do is prompt for a file to open, then open the same file in a different directory.  This came up with the correct response.  Thanks for your help guys.

var OpenDir = Folder ("/Users/ME/Desktop/Proof/")

var SourceFile = OpenDir.openDlg("Select Your Proof File",);

var SourceDir = Folder (SourceFile.parent.name);

alert("/Users/ME/Desktop/Layout" + SourceDir);

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