Copy link to clipboard
Copied
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.
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now