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

Volume name from File class ( Document saved )

Guide ,
Oct 04, 2023 Oct 04, 2023

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.

TOPICS
Scripting

Views

325

Translate

Translate

Report

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])
}  

Votes

Translate

Translate
Engaged ,
Oct 04, 2023 Oct 04, 2023

Copy link to clipboard

Copied

I think file.fullname will return the file path  

Votes

Translate

Translate

Report

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

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

 

//======

Screen Shot 2023-10-04 at 14.14.10.png

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank all. 

Peter, that did the trick.

 

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

 

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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

 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks for looking.

 

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

Votes

Translate

Translate

Report

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

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])
}  

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hello Rob,

That works on my Mac, thank you.

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

P.

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank for testing that.

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank you. 

 

 

Votes

Translate

Translate

Report

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