You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AppleScript引号问题排查:为何出现语法错误?

AppleScript语法错误解决:Finder选中文件用QuickTime Player打开

你的代码里的语法错误核心出在open theFile with application "QuickTime Player"这一行——Finder的open命令不支持with application这种写法,这才是触发语法报错的主要原因。另外如果遇到引号相关提示,检查是否不小心用了中文全角引号(“”),AppleScript只认英文半角引号("")。

给你两种可行的修正方案:

方案1:直接调用QuickTime Player打开选中文件

tell application "QuickTime Player"
    open (selection of application "Finder")
end tell

方案2:通过Finder指定应用打开(使用正确的参数)

tell application "Finder"
    set theFile to selection
    open theFile using application file id "com.apple.QuickTimePlayerX"
end tell

注:用应用ID(com.apple.QuickTimePlayerX)比应用名称更稳定,避免系统语言差异导致的识别问题

内容的提问来源于stack exchange,提问作者HNT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 03:45:32