2015-03-25 75 views
-3

Mac Yosemite 10.10.2。假设我有两个pdf,myPdf1.pdf和myPdf2.pdf,位于/ myFolder中。我想,做以下的服务或脚本:Mac Automator - 合并PDF文件,更改原始pdf文件的文件名,并将pdf文件保存在同名文件夹中,其名称为pdf 1

  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被转移到桌面上。

回答

0

我想出了一个使用AppleScript的解决方法,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 

运行结束