Re: get alias from ~/path
Re: get alias from ~/path
- Subject: Re: get alias from ~/path
- From: Andrew Oliver <email@hidden>
- Date: Sat, 01 Mar 2003 09:34:48 -0800
The best and safest option is to use the much-overlooked 'path to' command:
path to users folder
-->alias "Macintosh HD:Users:"
Or
path to current user folder
-->alias "Macintosh HD:Users:username"
This code is totally portable, and will work on any internationalized
system, including those where "Users" is not the name of the user folder.
The 'path to' command provides safe methods for locating many of the system
and user specific folders on a system.
Andrew
:)
On 2/28/03 10:53 PM, "Donald Hall" <email@hidden> wrote:
>
I have a situation where I want to be able to get an AppleScript
>
alias for a file from its POSIX path when the path is in the
>
shortened form "~/pathto/file". I need to be able to expand the tilde
>
into "/Users/username". Here is what I came up with:
>
>
set fileName to "~/CustomInfo.plist" -- just a file to do the test with
>
getAlias from fileName
>
>
to getAlias from pathName
>
if pathName starts with "~" then
>
set userName to do shell script "id -un"
>
set pathName to "/Users/" & userName & ,
>
"/" & (characters 2 thru -1 of pathName) as text
>
end if
>
set theAlias to alias POSIX file pathName
>
return theAlias
>
end getAlias
>
>
This seems to work on my machine. Is 'id' the right command to use?
>
There is also 'logname'.
>
>
Thanks,
>
>
Don
>
--
>
Donald S. Hall, Ph.D.
>
Apps & More Software Design, Inc.
>
email@hidden
>
http://www.appsandmore.com
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.