AppleScript equivilent of ~/directory (i.e. home folder)

Hello all-

I need a method to copy a file to the current users home folder like this:


Is there a proper way of getting the current user’s name and applying it to the path?


I understand that it needs to be in the POSIX format, but how to translate the tilde?


Does this work for you?

set userPrefs to path to "pref"
tell application "Finder" to duplicate file "path:to:plist" to userPrefs

The solution needs to be dynamic. That way if the default user changes, etc. the script doesn’t break. Does that make sense?

When I run:

set userPrefs to path to “pref”
– > alias “Powerbook G4:Users:rjj:Library:Preferences:”

I’m pretty sure that it will reflect the current user. If not, this should work (but I think it will result in the same thing).

set currUser to path to “cusr”
set prefs_ to (currUser as text) & “Library:Preferences:” as alias
– > alias “Powerbook G4:Users:rjj:Library:Preferences:”

And to get the posix, add:

set quotedPrefs to quoted form of POSIX path of prefs_
– > ‘/Users/rjj/Library/Preferences/’

The path to command has a number of parameters that should be able to help you;

path to current user folder → ~/


path to preferences → ~/Library/Preferences

would be the most pertinent to your request.

Since you’re probably using the Finder to duplicate whatever, you can just use the ‘home’ property. Something like this:

tell application “Finder”
duplicate folder “Test Folder” to home
end tell

where “Test Folder” is a folder on the desktop.