• 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: [SOLVED: Better] Getting file paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED: Better] Getting file paths


  • Subject: Re: [SOLVED: Better] Getting file paths
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 01 Oct 2005 07:37:35 -0700
  • Thread-topic: [SOLVED: Better] Getting file paths

On Wed, 28 Sep 2005 04:57:14 -0700, Killobit <email@hidden> said:
>i just further refined the AS to just these lines:
>
>tell application "Finder"
>     try
>         return the URL of target of front window
>     on error
>         return the URL of desktop
>     end try
>end tell

I'd suggest this:

tell application "Finder"
    set f to desktop
    if (count Finder windows) > 0 then
        set f to target of Finder window 1
    end if
    return POSIX path of (f as alias)
end tell

Reasons:

(1) You wanted a path, not a URL (I thought).

(2) "try" catches errors you might not expect, so you could "roll over" to
the desktop case without meaning to, and you lose the ability to learn what
the error really was. This way, if there's a real error, you'll hear about
it. :)

m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Next by Date: Re: AppleScript a miserable and utter failure
  • Next by thread: Re: AppleScript a miserable and utter failure
  • Index(es):
    • Date
    • Thread