Mac Automator-合并pdf,更改原始pdf的文件名,并将新的pdf保存在同一文件夹中,名称为pdf 1



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

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

我已经尝试了很多变通办法,但都无济于事。我在这里开始Mac Automator-合并PDF文件,保存在同一文件夹

我的问题是最后一步:将Finder项目移动到containerPath。我合并后的pdf文件被移到了桌面上。

我使用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

结束运行

相关内容

最新更新