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

Get script's folder from within the script


  • Subject: Get script's folder from within the script
  • From: Nicola Vitacolonna <email@hidden>
  • Date: Sun, 27 Dec 2009 16:34:43 +0100

Hi,
I have tried several ways (also discussed in this list) to get the containing folder of a script. The most general one that I have found so far (in ASUnit's documentation) is this:

property currentFolder : folder of file (document 1's path as POSIX file) of application "Finder"
display dialog currentFolder as text

It reports the script's path even within AppleScript Editor (whereas "path to me" does not). My questions are:

1) could someone explain me *why* it does work? And why the following does not?

tell application "Finder"
set currentFolder to the folder of file (path of document 1 as POSIX file)
end tell

Can’t make path of document 1 of application "Finder" into type POSIX file.

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?

Thanks in advance,
Nicola

AppleScript's version -- "2.1.1"
version of application "Finder" -- "10.6.2"
version of application "AppleScript Editor" -- "2.3"
 _______________________________________________
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

  • Follow-Ups:
    • Re: Get script's folder from within the script
      • From: "email@hidden" <email@hidden>
    • Re: Get script's folder from within the script
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: are finder items items? what is a vector?
  • Next by Date: Re: Get script's folder from within the script
  • Previous by thread: Merry Christmas!
  • Next by thread: Re: Get script's folder from within the script
  • Index(es):
    • Date
    • Thread