【问题标题】:Mac Automator - merge pdfs, change filename of original pdfs, and save new pdf in same folder with name of pdf 1Mac Automator - 合并 pdf,更改原始 pdf 的文件名,并将新的 pdf 以 pdf 1 的名称保存在同一文件夹中
【发布时间】:2015-05-28 13:42:28
【问题描述】:

Mac 优胜美地 10.10.2。假设我有两个 pdf,myPdf1.pdf 和 myPdf2.pdf,位于 /myFolder。我想要一个执行以下操作的服务或脚本:

  1. 将原始 pdf 重命名为 _MERGED_myPdf1.pdf 和 _MERGED_myPdf2.pdf
  2. 创建新合并的 pdf 并将其保存为 /myFolder/myPdf1.pdf

我尝试了许多解决方法,但均无济于事。我从这里开始Mac Automator - Combine PDF files, save in same folder

我的问题在于最后一步:将 Finder 项移动到 containerPath。我合并的 pdf 被移动到桌面。

【问题讨论】:

    标签: macos pdf applescript osx-yosemite automator


    【解决方案1】:

    我想出了一个使用 AppleScript 的解决方法,它可以绑定到 Automator 服务或应用程序中。我没有重命名输入的 pdf,而是将它们移动到一个文件夹中。

    on run {input, parameters}
    tell application "Finder"
        set trashFolder to "MacHD:path:to:some:folder"
        set outputFolder to container of (item 1 of input)
        set outputName to name of (item 1 of input)
        set outputFile to (outputFolder as text) & outputName
        repeat with p in input
            move p to trashFolder with replacing
        end repeat
        set pdfFiles to ""
        repeat with p in input
            set pdfFiles to pdfFiles & " " & quoted form of POSIX path of p
        end repeat
        --display dialog outputFile
        --display dialog pdfFiles       
        do shell script "/System/Library/Automator/Combine\\ PDF\\ Pages.action/Contents/Resources/join.py " & "-o " & quoted form of POSIX path of outputFile & pdfFiles
        return outputFile as alias
    end tell
    

    结束运行

    【讨论】:

      猜你喜欢
      • 2014-07-28
      • 2020-12-16
      • 1970-01-01
      • 2018-10-08
      • 1970-01-01
      • 1970-01-01
      • 2017-06-18
      • 1970-01-01
      • 2017-03-20
      相关资源
      最近更新 更多