我收到以下错误: "该文件与 QuickTime 播放器不兼容。
使用此脚本时:
tell application "Finder"
set random_file to some file of entire contents of folder "Movies" of home
open result
end tell
但是,我可以手动从查找器打开文件,一旦我这样做,脚本就会只处理该文件。问题是我有数千个文件,不想手动打开每个文件以使脚本再次工作。过去脚本没有这个问题。
我能想到两种方法来修改你的脚本:
坚持使用 Finder的
open
命令,但使用其using
参数完全调用它,该参数接受一个application file
,通知 Finder 将用于打开文件的应用程序。 这听起来可能是多余的,因为它已经尝试在 QuickTime 中打开它,我们并没有试图改变这一点,但看看它是否确实赋予了行为差异并不是不明智的:tell application id "com.apple.finder" tell the folder (path to movies folder) to tell (the ¬ a reference to entire contents) to tell (the ¬ some document file as alias) to set f to it open f using application file id "com.apple.QuickTimePlayerX" end tell
随心所欲地获取文件(实际上,您应该为此使用系统事件,而不是Finder,但我会使用您拥有的文件),但然后使用特定应用程序的
open
处理程序打开文件:tell application id "com.apple.finder" to tell the folder (path to movies folder) ¬ to tell (a reference to the entire contents) to tell (some document file) ¬ as alias to set f to it tell application id "com.apple.QuickTimePlayerX" activate open f end tell
注意。我正在使用蒙特雷,其中上述两个命题都恰如其分地起作用。 这并不一定推断它会在大苏尔这样做,但如果他们不这样做,则值得检查系统偏好设置的不同安全和隐私标题下的各种应用程序权限。