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

Re: Getting file paths


  • Subject: Re: Getting file paths
  • From: Killobit <email@hidden>
  • Date: Wed, 28 Sep 2005 04:39:42 -0700

THANK YOU!
i modified the code a bit to work the way i needed, for future reference here's the code:

on run
    try
        tell application "Finder"
            --attempt to get the URL of the front winodw (path)
            set thePath to URL of target of front window
            return thePath
        end tell
    on error error_name number error_number
        if (error_number = -1728) then -- no front window open
            try
                -- now lets, just get the path to the desktop folder
                tell application "Finder"
                    set thePath to URL of desktop
                end tell
            on error error_name number error_number -- some other error occurred, report it
                return "Error name:" & return & error_name & return & return & "Error number: " & error_number
            end try
        end if
    end try
end run


but one more quick question,
is it "bad form" to have a double try like that? or is there another way to do that?

thanks again
Eric

On Sep 28, 2005, at 4:10 AM, Jay Louvion wrote:

le 28/9/05 13:03, Killobit à email@hidden est réputé(e) avoir
écrit :

In that case I would throw in a "try" handler.
You can recuperate the kind of mistake, error nomber and then decide what
would want to do in such cases.

try
    tell application "Finder"
        set thePath to URL of container of item 1 of front window
        return thePath
    end tell
on error error_name number error_number
    display dialog "Error name:" & return & error_name & return & return &
"Error number: " & error_number
end try

HTH

J.


Jay Louvion
 _______________________________________________
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

  • Follow-Ups:
    • Re: [SOLVED: Better] Getting file paths
      • From: Killobit <email@hidden>
References: 
 >Re: Getting file paths (From: Jay Louvion <email@hidden>)

  • Prev by Date: Re: Object inheritance question, pt 2...
  • Next by Date: Re: [SOLVED: Better] Getting file paths
  • Previous by thread: Re: Getting file paths
  • Next by thread: Re: [SOLVED: Better] Getting file paths
  • Index(es):
    • Date
    • Thread