Re: Path to library folder w/ network home directory?
Re: Path to library folder w/ network home directory?
- Subject: Re: Path to library folder w/ network home directory?
- From: Sander Tekelenburg <email@hidden>
- Date: Wed, 23 May 2007 04:40:52 +0200
At 17:04 -0500 UTC, on 2007-05-21, Shandor Simon wrote:
> Chris Nebel, helped me work through this issue (thanks Chris!), but
> I thought I would share with the list the answer [...]
> I changed my code to:
>
> tell application "Finder"
>
> set profilefolders to folder "Profiles" of folder "Firefox" of
> folder "Application Support" of folder (path to library folder from
> user domain)
> ...
> end tell
Note that you don't need to ask for ~/Library, but can ask for
~/Library/Application Support diretcly:
path to application support folder from user domain
Don't worry about the below if you just intend to get something done quickly.
But if you plan to get a bit more serious with AS: as Chris pointed out "path
to" doesn't belong to the Finder, but to Standard Additions. It is generally
considered good style to not embed code in a tell block that it doesn't need
to be in. While you may get the anticipated result in one case, you may run
into a surprise in another. (Consider that "path to" may well mean something
else in different contexts -- tell blocks are such contexts.) It's easier to
avoid such problems by writing cleaner code.
In this case, that would mean doing something like this:
set libpath to path to application support folder from user domain
tell application "Finder"
set profilefolders to folder "Profiles" of folder "Firefox" of libpath
end
If you really want to write it all as one block, it seems you can do so thusly:
tell application "Finder"
set profilefolders to folder "Profiles" of folder "Firefox" of (my (path
to application support folder from user domain))
end tell
I should add though that I'd never considered spelling it this way and don't
recall having run into this construct before. So there might be reasons
against this. (I certainly don't consider this easy to read, but some
scripters seem to enjoy using illegibility for the sake of it ;))
Another thing to note is that whether your approach to use the Finder *at
all* may or may not be wise, depending on what you intend to do. It will fail
if those folders inside ~/Library/Application Support do not exist. You may
want it to fail under that condition. But it may be that you need the path
even when that Firefox folder does not exist. In that case, you would do this:
((path to application support folder from user domain) as Unicode text) &
"Firefox:Profiles:"
Look mom, no Finder.
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
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