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

Volume name from File class ( Document saved )

Guide ,
Oct 04, 2023 Oct 04, 2023

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.

TOPICS
Scripting
1.0K
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 , Oct 04, 2023 Oct 04, 2023

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])
}  
Translate
Engaged ,
Oct 04, 2023 Oct 04, 2023

I think file.fullname will return the file path  

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 ,
Oct 04, 2023 Oct 04, 2023

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

 

//======

Screen Shot 2023-10-04 at 14.14.10.png

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 ,
Oct 04, 2023 Oct 04, 2023

Hi @Pickory , You can easily do it with AppleScript, but the ExtendScript file path doesn’t seem to resolve the full absolute path

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 ,
Oct 04, 2023 Oct 04, 2023

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.

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 ,
Oct 04, 2023 Oct 04, 2023

Thank all. 

Peter, that did the trick.

 

Folder("~/Desktop/").parent.parent.parent.displayName

 

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 ,
Oct 04, 2023 Oct 04, 2023

I wonder, is this safe?

 

var p = app.activeDocument.fullName.parent;

var volName = "";

while ( p )

{

volName =  ( p.displayName )

p = p.parent;

}

alert ( volName );

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 ,
Oct 04, 2023 Oct 04, 2023

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('\/','') );

 

 

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 ,
Oct 04, 2023 Oct 04, 2023

Thanks for looking.

 

Are you running Windows? I am on Mac CC 2019.

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 ,
Oct 04, 2023 Oct 04, 2023

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])
}  
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 ,
Oct 04, 2023 Oct 04, 2023

Hello Rob,

That works on my Mac, thank you.

I wonder about removable / remote storage, mac and windows.

P.

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 ,
Oct 04, 2023 Oct 04, 2023

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 "~"

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 ,
Oct 04, 2023 Oct 04, 2023
LATEST

Thank for testing that.

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 ,
Oct 04, 2023 Oct 04, 2023

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
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 ,
Oct 04, 2023 Oct 04, 2023

Thank you. 

 

 

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