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" |