Applescript、POSIX文件名和Mountain Lion

Applescript、POSIX文件名和Mountain Lion,applescript,posix,Applescript,Posix,当我使用雪豹时,我在创建Applescripts时多次使用了以下模式: on run args set filePath to POSIX file (item 1 of args) as alias ... end run 升级到Mountain Lion后,上面的脚本似乎产生了一个警告: 2012-08-10 15:12:12.305 osascript[54131:303] CFURLGetFSRef was passed this URL which has n

当我使用雪豹时,我在创建Applescripts时多次使用了以下模式:

on run args
    set filePath to POSIX file (item 1 of args) as alias
        ...
end run
升级到Mountain Lion后,上面的脚本似乎产生了一个警告:

2012-08-10 15:12:12.305 osascript[54131:303]
CFURLGetFSRef was passed this URL which has no scheme
(the URL may not work with other CFURL routines): path/to/input/file.ext

有人能解释一下错误的含义吗?

一个简单的解决方法是在路径前面加上
文件://
。Mountain Lion希望所有内容都有URL,所以“裸”路径不起作用

例如,如果您想要
/Users/robertaloi/file.txt,您可以传入
file:///Users/RobertoAloi/file.txt`


CFURLGetFSRef的详细信息可在

上找到,这将澄清问题和解决方案。首先是问题

TB1T-Bboot:$ cat tmp.applescript
tell application "Finder"
        set MacOSpath to POSIX file "test-file" as alias
end tell
TB1T-Bboot:$ osascript tmp.applescript
2012-09-24 22:25:50.022 osascript[2564:707] CFURLGetFSRef was passed this URL which has no scheme (the URL may not work with other CFURL routines): test-file
alias TB1T-Bboot:Users:archive:test-file
TB1T-Bboot:$ 
现在没有问题了:

TB1T-Bboot:$ cat tmp.applescript
tell application "Finder"
        set MacOSpath to POSIX file "/Users/archive/test-file" as alias
end tell
TB1T-Bboot:$ osascript tmp.applescript
alias TB1T-Bboot:Users:archive:test-file
TB1T-Bboot:$

所以它抱怨路径是相对的,而不是绝对的。《狮子》中没有出现此警告。

雪豹会抱怨前缀吗?无法再测试它了,因为我切换到了ML。而且,这似乎对我不起作用,但我可能用错误的方式给它加了前缀。你能举个例子吗?