• 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: [Q] Get the folder the script is located in
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] Get the folder the script is located in


  • Subject: Re: [Q] Get the folder the script is located in
  • From: kai <email@hidden>
  • Date: Thu, 14 Sep 2006 22:52:41 +0100


On 14 Sep 2006, at 16:02, Eric Gorr wrote:

Michelle Steiner wrote:
On Sep 14, 2006, at 7:50 AM, Adam Bell wrote:
I would like to be able to get the folder my applescript is located in.

How can I do that?

set myFolder to ( get folder ... )

tell application "Finder" to set c to container of (path to me)
That does not work for scripts that are run from Script Editor; it returns the path to the script editor, and not to the script file.
It does work if the script is saved as an application or if the script is run from the script menu.

Is there any more general way of doing it so this would work as well?

Your script would need to check whether or not it is being run by Script Editor, Eric - perhaps something like this:


-----------
on |path to my folder|()
set f to path to me
tell application "Finder" to set SE to f is application file id "ToyS" as alias
if SE then set f to POSIX file (path of application "Script Editor"'s front document)
tell application "Finder" to f's folder as Unicode text
end |path to my folder|


display dialog |path to my folder|()
-----------

---
kai


_______________________________________________ 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
References: 
 >[Q] Get the folder the script is located in (From: Eric Gorr <email@hidden>)
 >Re: [Q] Get the folder the script is located in (From: Adam Bell <email@hidden>)
 >Re: [Q] Get the folder the script is located in (From: Michelle Steiner <email@hidden>)
 >Re: [Q] Get the folder the script is located in (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: Modifying Pitch Shift in QuickTime Player (was: no subject)
  • Next by Date: Re: Modifying Pitch Shift in QuickTime Player (was: no subject)
  • Previous by thread: Re: [Q] Get the folder the script is located in
  • Next by thread: Displaying the Restart Dialog
  • Index(es):
    • Date
    • Thread