Skip to main content
December 3, 2013
Question

Getting the computers username in to a text box in indesign

  • December 3, 2013
  • 1 reply
  • 1277 views

Hi

I'm totally new to scripting but at my firm they want to have a text box on their InDesign documents that will show the username of the computer. The idea is that this would be tagged a little like you do in data merge so the box would be '<<USERNAME>>' and this would automatically change to the name of the computer account using it. We did have aguy working on this but he left. I found a script on his computer that had the file 'username.jsx' in his InDesign scripts. When you open it simply has the line '$.getenv('USER')' in it but I have no idea how to make this work.

We are all working on macs.

Any help would be appreciated.

Thanks

Thom

This topic has been closed for replies.

1 reply

bagonterman
Inspiring
December 3, 2013

Yeah that should get the user. You could also do something like this.

if (File(["/Applications/OPCS"]).exists){

        var myFile2 = File(["/Applications/OPCS"]);

        myFile2.open("r",undefined,undefined);

        var computerOperator = myFile2.readln();

        myFile2.close();

    }

Then you will have to apply computerOperator to a text box.

December 4, 2013

Hi Gonterman1201

Thanks for your reply. I couldn't get your If statment to retun a value but I have managed to get the $.getenv('USER') statment working and returing the home folder name. Which has now presented a new problem. Though everyones account on their mac is now set to their name the orgional accounts for all our macs was set to 'macuser' and this is the name of their home folders. I have researched changing the home folder name but this means going through everyones computer and exporting their user accounts to a new account, something I would dearly like to avoid. Is there a a different comand i can use that will return the Account name other than the deep compter name? I thought it maybe something like $.getenv('ACCOUNT_ID') or something as simple as that.

Thanks once again for you reply.

Thom

bagonterman
Inspiring
December 4, 2013

This $.getenv('USER') should give you the user name. It would depend on what user they are using.