C-Command Software Forum

Is there an easy way to combine PDF files?

Hi,

I store a lot of PDF files in a single archive folder in Eaglefiler. The PDF files are from my Fujitsu Scansnap.

Things are working well. I have a few Applescripts to help my workflow. And I use PDFPen to edit the PDF files (getting rid of pages, or combining PDF files into 1).

Just wondering if anyone has an easy way of selecting 3-4 PDF files in EagleFiler, and combining them into a single PDF file? While deleting the original PDF files. There are paywares and freewares that combine PDF files. As mentioned, I use PDFPen. But it’s a bit clunky: because it involves opening the PDFFiles, selecting the pages, combining, saving, and then deleting the original files.

Has anyone written an Applescript that automates this? Otherwise, one of these months I’ll try to have a look about trying.

Thanks.

Just replying to my own message. (By the way, Michael Tsai, I haven’t figured out a way to create or reply to private messages).

After playing around with PDFPen’s Applescript library, I’ve figured out a way to easily combine PDFs.

Combining PDFs in PDFPen can be done without Applescript, but involves switching page views, selecting all, copy and pasting, which is a drag when I have 3 years worth of PDF files. Using AppleScript is much faster.

This results in one of the PDF files (the front one in PDFPen) having all the pages from the other files. Those other files are closed, but have to be manually deleted from EF.

This is the script I used. I’m not a very proficient AppleScript user. Feel free to change.

--combines PDF files. 
--adds files from behind the front window, to the back of the front 
--window. The arrangement of the final PDF pages, is determined by 
--how the user "arranged" them by clicking on each one in turn. 
--At the end, the only PDF file open, contains all the pages 
--from all the other PDF files. Those files can be deleted from EagleFiler. 
--EagleFiler will alter the page count on the final file, only when that
--file is previewed in EagleFiler. 
tell application "PDFpen"
    set NumDocs to count documents -- how many documents are open 
    if NumDocs > 1 then
        -- copy pages from each document to the front (or back) of the first document
        repeat with CurrDoc from 2 to NumDocs
            duplicate pages of document CurrDoc to back of pages of document 1
        end repeat
        tell document 1 to save -- save the front document 
    end if
    
    -- NOW, close all the windows except the front one (the one with the combined files. 
    if NumDocs > 1 then
        repeat with CurrDoc from 2 to NumDocs
            -- because documents are always closing, just close the 2nd document all the time. 
            close document 2
        end repeat
    end if
end tell

In order to prevent spam, only users who have posted a certain number of times can send private messages. (The restriction is in place if it says “New Member” next to your name.) You can always reach me by e-mail, of course.

Cool. Automator also has a built-in action that can do this, although I think that wants to create a new PDF file rather than replace an existing one.