Re: Scripting Filepaths
Re: Scripting Filepaths
- Subject: Re: Scripting Filepaths
- From: Chris Page <email@hidden>
- Date: Thu, 30 Jul 2009 14:53:13 -0700
On Jul 30, 2009, at 1:23 PM, J. Stewart wrote:
On 7/30/09 at 11:48 AM, James Bensley <email@hidden> spake
thusly:
set current_user to do shell script("whoami")
set file_path to "/Users/" & current_user & /Desktop/MyFile.abc"
OTH
set file_path to quoted form of posix path of ((path to "desk" as
text) & "MyFile.abc")
Doesn't launch a shell, accomplishes the same thing in one line and
is more reliable because the resulting path is properly escaped
regarding spaces and other special (shell) characters.
Most importantly, it doesn't hard-code how a user name is mapped to a
pathname. Never hard-code path elements like "/Users/" unless you have
no alternative. And don't assume the user name returned by "whois" is
the name of a directory inside "Users".
"path to" generally supplies the path to common directories.
--
Chris Page
The other, other AppleScript Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden