2015-03-25 170 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 

運行結束