Copy link to clipboard
Copied
Hi,
I have an InDesign document that has been saved. I would like to know the volume name that the document is saved on.
File and Folder class are not offering much.
Thank you.
P.
Maybe this?
var sv = Folder("~/Desktop/").parent.parent.parent.displayName
var fp = app.activeDocument.filePath.toString()
if (fp[0] == "~") {
alert("Document Volume: " + sv)
} else {
alert("Document Volume: " +fp.split("/")[1])
}
Copy link to clipboard
Copied
I think file.fullname will return the file path
Copy link to clipboard
Copied
Thank you for your reply.
It does not work for me 😞
//=======
alert ( app.activeDocument.fullName + "\r" +
app.activeDocument.fullName.displayName + "\r" +
app.activeDocument.fullName.fsName + "\r" +
app.activeDocument.fullName.fullName + "\r" +
app.activeDocument.fullName.path + "\r" +
app.activeDocument.fullName.relativeURI + "\r")
//======
Copy link to clipboard
Copied
Hi @Pickory , You can easily do it with AppleScript, but the ExtendScript file path doesn’t seem to resolve the full absolute path
Copy link to clipboard
Copied
You have this problem only with files on your desktop. To get the drive/volume name you'ld do
Folder("~/Desktop/").parent.parent.parent
P.
Copy link to clipboard
Copied
Thank all.
Peter, that did the trick.
Folder("~/Desktop/").parent.parent.parent.displayName
Copy link to clipboard
Copied
I wonder, is this safe?
var p = app.activeDocument.fullName.parent;
var volName = "";
while ( p )
{
volName = ( p.displayName )
p = p.parent;
}
alert ( volName );
Copy link to clipboard
Copied
It's not safe because (over here) it always returns null, whether the file is on the desktop or anywhere else. That's because of the addition of displayName. That may be a bug, no idea.
The only way I could get it to work is with this mongrel:
var p = app.activeDocument.fullName.parent;
var temp = app.activeDocument.fullName;
while ( p ) {
temp = p;
p = p.parent;
}
alert ( temp.fullName.replace('\/','') );
Copy link to clipboard
Copied
Thanks for looking.
Are you running Windows? I am on Mac CC 2019.
Copy link to clipboard
Copied
Maybe this?
var sv = Folder("~/Desktop/").parent.parent.parent.displayName
var fp = app.activeDocument.filePath.toString()
if (fp[0] == "~") {
alert("Document Volume: " + sv)
} else {
alert("Document Volume: " +fp.split("/")[1])
}
Copy link to clipboard
Copied
Hello Rob,
That works on my Mac, thank you.
I wonder about removable / remote storage, mac and windows.
P.
Copy link to clipboard
Copied
It works for me with either a networked or attached volume. If it’s not the start up volume the string is something like /VolumeName/Users/usename or /VolumeName/TestFolder/test.indd. Looks like a startup drive file path always starts with "~"
Copy link to clipboard
Copied
Thank for testing that.
Copy link to clipboard
Copied
I am on Mac CC 2019.
AppleScript is more straight forward:
tell application id "com.adobe.indesign"
set AppleScript's text item delimiters to ":"
set d to file path of active document as string
set w to word 1 of d
set AppleScript's text item delimiters to ""
display dialog ("Document Volume: " & w)
end tell
Copy link to clipboard
Copied
Thank you.