Home folder path

Hello all-

Is there a easy way to get the path to a users home folder? I have tried this:

tell application "Finder"
	
	set homdir to home
	
	return homdir
	
end tell

and I get this returned

folder “admin” of folder “Users” of startup disk of application “Finder”

What I really want is a way to use a path something like this

“~/Library/Preferences”

but I cant for the life of me figure a way to make this work. Every computer here has a different HD name, so it can’t be hard coded either. Any sugestions?

Thanks for the help
John

tell application "Finder"
	
	set homdir to home as alias
	
	return homdir
	
end tell

If you wanted a string, it would be:

tell application "Finder"
	
	set homdir to (home as alias) as string
	
	return homdir
	
end tell

Check out Rob Jorgensen’s excellent Show Path Codes script, at our ScriptBuilders section.

Thanks for the reference - I keep forgetting that script exists. I can never remember the code for current user:


path to "cusr"

There are a few other ways to get the paths to folders without having to use the ‘Computers Hard Drive’ name…

get quoted form of POSIX path of (path to preferences folder from user domain) -- slash "/" delimited path
--> "'/Users/username/Library/Preferences/'"
get POSIX path of (path to preferences folder from user domain) -- slash "/" delimited path
--> "/Users/username/Library/Preferences/"
get (path to preferences folder from user domain) -- colon delimited path
--> alias "Mac HD:Users:username:Library:Preferences:"
do shell script "cd $HOME/Library/Preferences/;open ." -- opens the folder