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?
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)
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!
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
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!
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.
Copy link to clipboard
Copied
File("~/Desktop/stest.jsx").fsName
Result: C:\Users\xbytor\Desktop\stest.jsx
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);
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.
Copy link to clipboard
Copied
File('~').parent.parent.displayName for the Mac
File('~').parent.parent.name for Windows