Re: Scripting Filepaths
Re: Scripting Filepaths
- Subject: Re: Scripting Filepaths
- From: Jon Rosen <email@hidden>
- Date: Wed, 29 Jul 2009 21:08:55 -0400
Thanks, Tim. I actually need to find the path to the user's Library.
"~/Library" does not appear to work and Path to Library Folder only
returns the Mac HD's Library. Is there a shortcut for that?
I almost had the container example correct. I had been trying some
similar variations that included things like (the_file as text) and
set the_file to (choose file as text). Only your specific syntax seems
to work. Is there any reference material that will clarify this a bit.
I could have been trying variations for hours before I hit on the
exact syntax. AppleScript seems very unforgiving when it comes to
filepaths.
Thanks,
Jon
On Jul 29, 2009, at 8:48 PM, Tim Mansour wrote:
2009/7/30 Jon Rosen <email@hidden>:
I can use path to desktop or /Desktop for the Mac's desktop
I think you might have misunderstood what the desktop is, Jon. If you
use "path to desktop" you get the path to the current user's desktop
folder, eg:
alias "Macintosh HD:Jon:Desktop:"
In other words, there is no "Mac's desktop", there's only a user's
desktop. Without having to enter the user's name in a script,
therefore, you can use this:
set file_name to "Sheaffer Flattop.png"
open file ((path to desktop as text) & file_name)
To get the enclosing folder of an item you can either extract it from
the full path using string handling, or you can use the Finder's
"container" property:
set the_file to (choose file)
tell application "Finder" to set the_folder to container of the_file
as text
--
Tim Mansour <email@hidden>
"The decadent international but individualistic capitalism in the
hands of which we found ourselves after the war is not a success. It
is not intelligent. It is not beautiful. It is not just. It is not
virtuous. And it doesn't deliver the goods." -- John Maynard Keynes
_______________________________________________
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