Skip to main content
Whatevermajorloser
Inspiring
November 3, 2015
Answered

How to specify folder location on user's desktop?

  • November 3, 2015
  • 2 replies
  • 1212 views

I'm writing a script that will be stored on a shared server and accessed via an action by multiple users. The script would eventually save images into an already created folder on their respective desktops. This folder would have the same name for everyone, but seeing as each users path would differ due to their usernames, how do I make the save location in the script just point to that folder on the users desktop regardless of username?

Edit: Wait, would it be a matter of doing something like this: '~/Desktop/StandardUpload/' ?

This topic has been closed for replies.
Correct answer 37105686

Thats exactly it.  ~/Desktop/StandardUpload/  or whatever path.  I use it all the time for the scripts my team runs.   There are ways to get specific username data, but if your not interested, this works perfectly

2 replies

DBarranca
Legend
November 4, 2015

Hi,

I wouldn't mess with envars, just use Folder tokens - easier, safer:

// Folder.desktop;

var myPath = Folder.desktop + "/whatever/you/need.js";

Works on both Mac and Win. Other tokens in the JS Tools Guide, pagg. 56-57.

Cheers,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

Whatevermajorloser
Inspiring
November 4, 2015

Ah, great to know! Thank you, Davide.

37105686Correct answer
Participating Frequently
November 3, 2015

Thats exactly it.  ~/Desktop/StandardUpload/  or whatever path.  I use it all the time for the scripts my team runs.   There are ways to get specific username data, but if your not interested, this works perfectly

Whatevermajorloser
Inspiring
November 4, 2015

Great, thanks!

I'd actually love to know how to find out the username if you don't mind sharing?

Participating Frequently
November 4, 2015

Do you know what it would be on a mac?


    x = new Folder("~");

    userName = x.fsName.match(/[A-Z]+$/i);

Thats what I use on the Mac side of things. Hope this helps