参考:
http://apple4.us/2007/12/write-your-first-applescript.html
http://apple4us.com/2007/12/applescript-finder-commands/
http://www.sjsjw.com/kf_mobile/article/4_3329_12038.asp
当然我们可以将choose file / folder和open file/folder/alias结合来使用。这样就不需要我们手动去填充文件和文件夹的路径了。例如:
set filePath to choose file
tell application "Finder"
open file filePath
end tell
filePath
上面的是选取文件后也打开了文件,但是只想获取文件路径而不打开文件,可以使用下面的语句:
// open Finder in a special path
// NSAppleScript *script = [[NSAppleScript alloc] initWithSource: @"tell application \"Finder\" to open location \"file:///Users/mac/Documents\""];
// open Finder to choose a file
NSAppleScript *script = [[NSAppleScript alloc] initWithSource: @"set fileChosen to choose file\n set filePath to POSIX path of fileChosen\n do shell script \"echo srm -rfv -m \" & quoted form of filePath"];
NSAppleEventDescriptor *event = [script executeAndReturnError: nil];
这样文件路径指针就包含在 event 中了