Automator workflow to combine PDFs - how to control location of output?

I’ve been using this helpful workflow for almost four years to select multiple PDFs in the Finder and knit them together into one PDF document, but it has a flaw: the “Move Finder Items” action can only put the resulting file in a specific folder, “Financial Statements.”

What action would place the resulting file in the same place I started?

  • If I remove “Move Finder Items” action and leave “Reveal Finder Items,” the file appears deep in the computer’s guts: private > var > folders > 4h > T …

  • If I remove “Reveal Finder Items” so that the workflow consists of the “Combine PDF Pages” action, then I can’t find the file at all.

It’s still great using this – I generate 5-8 one-page PDFs from Google Drive, then use this workflow to merge the pages together into a financial report. But it would better if it would do its work where I want it to, in a year-month directory beneath “Financial Statements.”

Thanks!

If you are willing to use Hazel, this approach (as best I understand your question) should work. Run the Automator script that you have provided. Then let Hazel take over the job of placing the resulting file in the appropriate location.

Hazel monitors your folder that you call Financial Statements. When a new PDF appears in the folder (which is what your automator script does) Hazel springs into action. It is waiting for any PDF to get put into the folder Financial Statements.

Rename: It renames the file current date_FinancialReport.pdf. When I ran your automator script, the name of the created concatenated PDF was inscrutable so Hazel renames it 2018-09-14_114509_FinancialReport. The name of the file becomes: YYYY-MM-DD_HHMMSS_FinancialReport. My example makes the preface to the name detailed down to the second. If this is overkill, you can modify (edit) what Hazel presents as the current date. Below is a picture of that editor. I have included text down to the second.

Sort into subfolder: It takes this renamed file (2018-09-14_114509_FinancialReport) and puts it into a subfolder called current date, (example: 2018-09). In this case current date is edited to be YYYY-MM. If the folder of this name does not yet exist, it is created. This folder is a subfolder of Financial Statements.

This works for me. Hazel is an app that anyone interested in automation should buy IMO. A similar workflow could be created in Keyboard Maestro but I think that the Hazel workflow is simpler and clearer.

The final step in your automator script (Reveal Finder Items) is no longer necessary and should be removed.

2 Likes

I’ve seen AppleScript solutions for grabbing the file path and using it to save the output files, which you can add to the Automator workflow: https://stackoverflow.com/questions/24087228/mac-automator-combine-pdf-files-save-in-same-folder

You could also select Options under the Move Finder Items and check “Show this action when the workflow runs” to get a prompt for you to chose the output path.

If you happen to have Alfred, there is a great workflow called Alfred PDF Tools which makes merging PDFs (and splitting, etc) super easy: https://www.alfredforum.com/topic/9276-alfred-pdf-tools-–-optimize-encrypt-and-manipulate-pdf-files/

2 Likes

It WORKS! Thank you! You know that image of Snoopy from Peanut, dancing on top of his doghouse? Pretend to see Otto the Automator doing that.

I modelled the new workflow after the second one in the Stack Overflow thread, tweaks by “Dr. Tofu.” See screenshot below.

<Complaint> why doesn’t Automator have some of these obvious actions built in by now? like “Get folder name in Finder” or “Get pathname from Finder” or even built-in variables like “Today’s Date” token with parameters to modify the format, like in Hazel? Do I have an old model or something and it hasn’t been updated?</Complaint>

Next I want something to automatically instruct PDFPen “Insert Page Numbers in top right header.” Then this will really be going places. Thanks again!

1 Like

Next I want something to automatically instruct PDFPen “Insert Page Numbers in top right header.” Then this will really be going places. Thanks again!

I can only use AppleScript to the extent that I can slightly modify somebody else’ s script. So I cannot take your request any further.

But it appears that the Scripting commands of PDFPenPro v10 have what you would need.