get alias from ~/path
get alias from ~/path
- Subject: get alias from ~/path
- From: Donald Hall <email@hidden>
- Date: Fri, 28 Feb 2003 23:53:53 -0700
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.