• 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: POSIX file question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Path relative to current script? Re: POSIX file question
      • From: Don Briggs <email@hidden>
References: 
 >POSIX file question (From: Donald Liu <email@hidden>)

  • Prev by Date: Re: Simple question - how2 launch apps in OS X via a script
  • Next by Date: Re: Need to script tracking in multiple Quark files-correction
  • Previous by thread: POSIX file question
  • Next by thread: Path relative to current script? Re: POSIX file question
  • Index(es):
    • Date
    • Thread