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

如何创建Automator快速操作 逐次对文件夹内每个PDF运行指定AppleScript

配置流程

1. 创建快速操作基础框架

  • 打开Automator应用,新建项目时选择「快速操作(Quick Action)」类型
  • 顶部参数配置:
    • 工作流接收:选择 文件夹
    • 位于:选择 Finder.app
  • 从左侧动作库依次添加以下动作到右侧工作流区:
    1. 「获取文件夹内容」:如果需要处理子文件夹内的PDF,勾选动作里的「重复每个子文件夹」,不需要则保持默认
    2. 「过滤访达项目」:添加后配置规则为 文件扩展名 是 pdf,自动筛选出所有目标PDF文件
    3. 「运行AppleScript」:删除动作自带的默认代码,替换为下文修改后的适配批量执行的代码

2. 适配批量顺序执行的AppleScript代码

你原来的代码仅支持处理单个传入文件,修改后代码如下,会自动遍历所有筛选出来的PDF文件,上一个文件的处理流程完全结束后才会启动下一个:

on run {input, parameters}
    -- 遍历所有传入的PDF文件,逐个处理
    repeat with theFile in input
        set theSeconds to time of (current date)
        -- 注意:请将下方路径替换为你自己的template.indd实际存储路径
        tell application "Finder"
            set theDuplicate to duplicate file "Macintosh HD:Users:username:Documents:IddTest:template.indd"
        end tell

        tell application "Adobe InDesign 2020" to open file (theDuplicate as string)

        tell application "Adobe InDesign 2020"
            if document 1 exists then
                repeat 34 times
                    tell document 1
                        relink link "placeholder.pdf" to theFile
                        try
                            update link "placeholder.pdf"
                        end try
                    end tell
                end repeat
            end if
            close document 1 saving yes
        end tell

        tell application "Finder"
            set name of theDuplicate to "" & theSeconds & ".indd"
        end tell
    end repeat
end run

注意:使用前务必将代码中的模板路径修改为你本地template.indd的实际路径,同时确认你的InDesign模板中确实存在名为placeholder.pdf的链接资源。

3. 保存与使用

  • 按⌘+S保存快速操作,自定义命名例如「批量PDF生成Indd」,系统会自动存储到对应快速操作目录
  • 使用时右键点击任意文件夹,在右键菜单的「快速操作」分类下找到你保存的动作,点击即可自动执行,无需手动选择PDF文件,会自动识别文件夹内所有PDF按顺序处理。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 02:45:01