Re: POSIX file question
Re: POSIX file question
- Subject: Re: POSIX file question
- From: Christopher Nebel <email@hidden>
- Date: Thu, 23 Oct 2003 18:29:18 -0700
On Oct 22, 2003, at 4:07 PM, Donald Liu wrote:
I have a bad feeling that this has been discussed before, but I'm
currently blanking out and can't figure out what I'm doing wrong. I
searched and found few on the Apple/AppleScript web-site, they didn't
provide the solution I'm looking for. If anyone can help me, I'd
really appreciate it.
If I have the following POSIX path,
set foo to "~/Documents/QuickLooks/"
and want to convert it to the AppleScript file object, I do this...
set goo to POSIX file foo
but this returns ":~:Documents:QuickLooks:". How do I make it so that
it returns "Macintosh HD:Users:dliu:Documents:QuickLooks:"
The "POSIX file" class doesn't handle ~ specially, like the shell does.
(There is an enhancement request filed on this.) To get the effect
you're looking for, you have to ask someone where the home directory is
and tack that on somehow. Here are a two ways:
set foo to (do shell script "echo ~") & "/Documents/QuickLooks/"
set goo to POSIX file foo
set foo to (system attribute "HOME") & "/Documents/QuickLooks/"
set goo to POSIX file foo
Alternatively, you could approach the problem sideways:
tell application "Finder"
get folder "QuickLooks" of folder "Documents" of home as alias
get folder "Documents:QuickLooks" of home as alias
-- or, let the system find the Documents folder for you...
get folder "QuickLooks" of (path to documents folder) as alias
end tell
(Depending on the eventual destination, you may or may not need the "as
alias".)
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.