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

Can you look up a Hard Drive name in Extendscript?

Enthusiast ,
Nov 06, 2014 Nov 06, 2014

Copy link to clipboard

Copied

I'm running:

alert(Folder.desktop.fsName)

Which brings up:

/usr/home/<<userName>>/Desktop

I need it to bring up:

<<hardDriveName>>/usr/home/<<userName>>/Desktop

Ex. Macintosh HD/usr/home/tferguson/Desktop

Is this possible with Javascript/Extendscript?

TOPICS
Actions and scripting

Views

876

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
Adobe
Community Expert ,
Nov 07, 2014 Nov 07, 2014

Copy link to clipboard

Copied

On Win, this alert will show "C:\". Might work the same on Mac.

#target photoshop

var user = new Folder('~/')

alert(user.parent.parent.fsName)

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
Enthusiast ,
Nov 07, 2014 Nov 07, 2014

Copy link to clipboard

Copied

As is, this script still shows /usr as the path. To get to what would be the hard drive its:

var user = new Folder('~/')

alert(user.parent.parent.parent.parent.fsName)

But this errors out, as there's no data beyond this. Tried it also without fsName, and it just returns null. Good thought though!

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
Enthusiast ,
Nov 11, 2014 Nov 11, 2014

Copy link to clipboard

Copied

In windows you get the user name like this:

$.getenv("USERNAME");

And if you want the name of the PC:

$.getenv("COMPUTERNAME");

Do not know on Mac

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
Explorer ,
Nov 14, 2014 Nov 14, 2014

Copy link to clipboard

Copied

I'm on a mac, don't know if this makes a difference or not, but i've always used this to find the full path name.  It just drops the "/Volumes" from the path. Which would still give you the HDD that your working from.

example:

alert(activeDocument.fullName.toString()); 

That should pop up with the full path of the file.  You can drop the toString(), also I just happened to have spaces in the path of the document I opened to try this with.

Hope this helps!

Screen Shot 2014-11-14 at 7.17.47 AM.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
Enthusiast ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

Thanks for this, sorry for the delayed reply, when you grab from Desktop, it goes with ~/Desktop, instead of giving the full 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
Advisor ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

File("~/Desktop/stest.jsx").fsName

Result: C:\Users\xbytor\Desktop\stest.jsx

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
Enthusiast ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

I have tried on Macintosh OS 10.8.5/64 and this went well

var system = $.os; // it gives the "Macintosh OS 10.8.5/64" in my case

var userName = $.getenv("USER"); // on Mac, it gives the active user name

var userBaseFolder = Folder("/Users/" + userName); // gives '~'

var computerName = userBaseFolder.parent.parent.displayName; // in my case it gives 'Macintosh HD'

// the next Folder is exactly the same as  /Users/[userName]

// also the next Folder is exactly the same as  ~

Folder("/" + computerName + "/Users/" + userName);

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
Enthusiast ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

Will give it a shot. I believe I tried something similar, and it errored out and wouldn't go higher than "~".

fsName did not work in the past on Mac.

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
Advisor ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

LATEST

File('~').parent.parent.displayName for the Mac

File('~').parent.parent.name for Windows

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