• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Filepaths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Scripting Filepaths
      • From: Tim Mansour <email@hidden>
References: 
 >Scripting Filepaths (From: Jon Rosen <email@hidden>)
 >Re: Scripting Filepaths (From: Tim Mansour <email@hidden>)

  • Prev by Date: Re: Scripting Filepaths
  • Next by Date: Re: Excel (2004) Hidden rows show up in tab delimited text file
  • Previous by thread: Re: Scripting Filepaths
  • Next by thread: Re: Scripting Filepaths
  • Index(es):
    • Date
    • Thread