这个applescript有效
set myFile to (POSIX path "/Users/fred/Documents/data.dat")
这个小程序不起作用
set myFileName to "/Users/fred/Documents/data.dat"
set myFile to (POSIX path myFileName)
它因错误而失败
get POSIX file "/Users/fred/Documents/data.dat"
--> error number -1728
Result:
error "iTunes got an error: Can’t get POSIX file \"/Users/fred/Documents/data.dat\"." number -1728 from file "Macintosh HD:Users:drew:Desktop:Music:DIY:DIY-01.mp3"
看起来好像在使用变量时,POSIX 路径包含双引号作为文件名中的显式字符。我究竟做错了什么?
下面的脚本重现了该问题。
tell application "Finder"
set newFileName to "/Users"
set newFile to POSIX file newFileName
end tell
谢谢