Getting path to user's home directory

I have some Applescripts that I've written at work and I'd like to share with coworkers. The problem is that I've currently got my home directory path hard-coded in some of them, e.g.

set theScript to load script file ":Users:bmargoli:Library:Scripts:Lib:RunInTerminal.scpt"

I'd like to rewrite this to be more portable, so everyone doesn't have to personalilze their copies of the scripts. How would I rewrite the above line to get the user's home directory, and then find the Library/Scripts/Lib folder within it.

MacBook, Mac OS X (10.4.11)

Posted on Aug 6, 2008 4:29 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 6, 2008 7:47 PM

Try using:

alias ((path to home folder as string) & "Library:Scripts:Lib")

(34492)
8 replies

Aug 6, 2008 6:31 PM in response to Barry Margolin

Here's two examples...

open the Lib folder...
try
do shell script "open ~/Library/Scripts/Lib\\ folder"
end try
move the Lib folder to the desktop...
tell application "Finder"
set home_path to home as Unicode text
try
set source to alias ( home_path & "Library:Scripts:Lib folder") as Unicode text
set destination to home_path & "Desktop" as Unicode text
tell application "Finder" to move source to destination as Unicode text
end try
end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Getting path to user's home directory

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.