• 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: Get script's folder from within the script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get script's folder from within the script


  • Subject: Re: Get script's folder from within the script
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 27 Dec 2009 14:56:46 -0800


On Dec 27, 2009, at 7:34am, Nicola Vitacolonna wrote:

2) Are there any drawbacks in using the method above (e.g., situations in which it would not work)? Or is it a “safe” way for a script to know its location in the file system?


There are drawbacks to using a property definition to id a script's location.  By itself, it won't work.

The value of a property declaration is only used the first time a script is executed.  Once that value is set, it remembers it through subsequent runs, and does not execute again.

Try this:

property now : time string of (current date)

display dialog now


Run that script several times and the time doesn't change (unless you compile).

So you're better off with something like this:

property scriptPath: ""

on run
set scriptPath to posix path of path to me
---- you're stuff here
end run


ES
 _______________________________________________
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

References: 
 >Get script's folder from within the script (From: Nicola Vitacolonna <email@hidden>)

  • Prev by Date: Re: are finder items items? what is a vector?
  • Next by Date: Re: are finder items items? what is a vector?
  • Previous by thread: Re: Get script's folder from within the script
  • Next by thread: Re: Get script's folder from within the script
  • Index(es):
    • Date
    • Thread