Re: Scripting Filepaths
Re: Scripting Filepaths
- Subject: Re: Scripting Filepaths
- From: Tim Mansour <email@hidden>
- Date: Thu, 30 Jul 2009 11:37:18 +1000
2009/7/30 Jon Rosen <email@hidden>:
> I actually need to find the path to the user's Library.
OK, you need to check the syntax for the "path to" command in the
Standard Additions. One of the optional parameters specifies which
"domain" you're looking at:
path to library folder from user domain
--> alias "Macintosh HD:Users:jon:Library:"
path to library folder from system domain
--> alias "Macintosh HD:System:Library:"
path to library folder from local domain
--> alias "Macintosh HD:Library:"
What you've discovered is that the local domain is the default for
"path to library folder" when no domain is specified.
> AppleScript seems very unforgiving when it comes to filepaths.
While we're there you might also note in its dictionary that "path to"
can take a parameter "as string" or "as alias":
path to library folder from user domain as string
This is subtly different to:
(path to library folder from user domain) as text
... in which "path to ..." returns an alias which is then coerced to
text by AppleScript. Hence, the former version is more efficient.
> AppleScript seems very unforgiving when it comes to filepaths.
Depends on your perspective. We've all been through the confusion;
thankfully I had an excellent teacher (thanks Shane!). But some would
say much of the confusion comes from parts of AS being *too* forgiving
and automatically coercing form one thing to another.
The AppleScript Language Guide on developer.apple.com is a good place
to start, make sure you read the section on files & aliases.
--
Tim Mansour <email@hidden>
"The least initial deviation from the truth is multiplied later a
thousandfold." -- Aristotle
_______________________________________________
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