Getting the currently running "Shortname"

Hi guys,
i am writing a script and in it i am using the following line:

set AppleScript's text item delimiters to "/Users/admin/Public"

in this line i am using the shortname “admin”…is there a way to let the script find out what is the “Shortname” running now and replace it instead.

thx.!!

:slight_smile:

Hi Tony,

You can use this:

set publFolder to (path to “pubb”)
set uPath to posix path of publFolder

gl,

Thx man,
this could be a solution except that i prefer to have this path: “Users/admin/Public” without the last character “/”…instead in the script u gave me i am reveiving “Users/admin/Public/”…i am not sure if it is that urgent…but if it can b done it would be fine.:smiley:

Hi Tony,

I thought folders end with “/”. Here’s how you can get rid of it:

set publFolder to (path to “pubb”)
set uPath to POSIX path of publFolder
if uPath ends with “/” and length of uPath is > 1 then set uPath to text 1 through -2 of uPath

Editted: another way but I don’t know if it works all the time or if it’s better.

set user_Path to (path to “cusr”) as string
POSIX path of (user_Path & “Public”)

gl,

If you just want to return the POSIX path of the user’s Public folder, you can do this (which can then be used as a delimiter if you need it):

tell application "System Events" to set publicFolder to POSIX path of (public folder of user domain)

If you specifically need the user’s short name for some other purpose, as well:

tell application "System Events" to set shortName to (name of current user)