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

Automator文件夹动作中AppleScript无法运行的问题排查求助

Automator与AppleScript文件夹动作故障排查

1. Automator初始实现尝试

通过Automator创建文件夹动作:

  • 使用「Folder Action」模块指定目标文件夹
  • 仅添加「Execute AppleScript」模块,代码如下:
on run {input, parameters}
    set fileName to name of (item 1 of input)
    display dialog fileName
end run

预期验证文件放入目标文件夹后能被识别并弹出对话框,但实际无反应。已确认工作流与文件夹绑定正常(替换为「Delete File」模块可执行),最初怀疑是权限问题。

2. 直接AppleScript文件夹动作测试

跳过Automator,编写独立的AppleScript文件夹动作脚本:

on adding folder items to this_folder after receiving these_items
        display dialog (item 1 of these_items) as text
end adding folder items to

该脚本可正常运行,证明文件夹绑定有效,these_items参数能正常传递。但以下修改后的脚本无法运行:

on adding folder items to this_folder after receiving these_items
    tell application "Finder"
        set fileName to name of (item 1 of input)
        display dialog fileName
    end tell
end adding folder items to

3. 再次测试Automator中的脚本

调整Automator内的AppleScript代码:

on run {input, parameters}
    tell application "Finder"
        set fileName to name of (item 1 of input)
    end tell
    display dialog fileName
end run

该脚本可正常运行。

故障原因总结

直接使用AppleScript文件夹动作时,误将参数名these_items写为input,修正参数名后,Automator和独立AppleScript两种实现方式均正常运行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 02:05:18