Pointing to Users Documents folder

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

norm

Pointing to Users Documents folder

Post by norm »

Hi guys need a little help here.

Im looking for a clever way using scripting to point to the users documents folder, obviously the script would have to get be able to identify the users os login name in order to correctly point to the users docuemnts folder.

In flash builder and air its done simply by using "documentsDirectory"

Code: Select allvar file:File = File.documentsDirectory.resolvePath("AIR Test");

Im looking for a way to do it using a ps script to. I currently use this to load a local file using ps scripting.

Code: Select allvar strPlugInsFolderDirectory = localize("$$$/private/Plugins/DefaultPluginFolder=Plug-Ins") + "/" ;
var filePath = new File(app.path.toString() + "/"  + strPlugInsFolderDirectory + "Panels/pluginX.assets/email.psd" );

The above obviously loads from the Panels folder for the PS version the script is run in.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

Pointing to Users Documents folder

Post by Paul MR »

The users folder is referenced by "~" I.E. this will open the users folder in explorer/finder
Code: Select allFolder("~").execute();


If you are referencing the assets folder from a panel you should be able to do this with ...
Code: Select allapp.load(new File(assetsPath + "/ActionSet.atn"));
norm

Pointing to Users Documents folder

Post by norm »

Awesome Paul, thats it!
Mikaeru

Pointing to Users Documents folder

Post by Mikaeru »

norm wrote:Im looking for a clever way using scripting to point to the users documents folder, obviously the script would have to get be able to identify the users os login name in order to correctly point to the users docuemnts folder.

In flash builder and air its done simply by using "documentsDirectory"

Also, from Photoshop CS2 or later, there are two Folder class properties which may be helpful:

myDocuments
A Folder object for the default document folder. Read-only.
● In Windows, C:\Documents and Settings\username\My Documents
● In Mac OS, ~/Documents

userData
A Folder object for the folder that contains application data for the current user. Read-only.
● In Windows, the value of %APPDATA% (by default, C:\Documents and Settings\username\Application Data)
● In Mac OS, ~/Library/Application Support

Code: Select allalert (Folder.myDocuments);
alert (Folder.userData);