Export from Day One and Append to Another PDF

I keep my daily journal in DayOne. I’d like to create a macro that exports the current DayOne entry as a PDF, and then appends that to a another PDF where I’m keeping all my daily entries. How can I accomplish that second part? Thanks.

You can use this in Execute a Shell Script:

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/MacOS/join -o combined_new combined_old new_pdf
  • "combined_new" there is a placeholder for the path to the PDF file that is to combine all previous PDFs.
  • "combined_old" is a placeholder for the path to the first input file, which will be the previous compilation of PDFs.
  • "new_entry" is a placeholder for the path to the pdf of your new journal entry.

You will probably want to use a local variable for each path. Your macro will also need to take account of the fact that "combined_new" will be "combined_old" on each execution of the action, in order to create a new "combined_new".

I hope my explanation makes sense. If you experiment with the shell command I'm sure that all will become clear!

Thanks so much. I’ll give this a shot!

1 Like

I almost have it running, but the Shell Script won’t execute. What am I doing wrong?

You can't reference variables directly in shell scripts; use this form:

"$KMVAR_new_entry" and "$KMVAR_combined_old". Basically, put it all in quotes, and preface the variable name with $KMVAR_. Any spaces in the variable name need to be replaced with underscores.

It's all explained in the Using KM Variables section of the Shell Script wiki page.

-rob.

Great. I’ll give that a shot.

Okay, the action never seems to fire. Here’s how I have it now:

Can you share the full macro?

-rob.

Sure. Here you go:

Export PDF and Append to PDF Journal.kmmacros (31.0 KB)

Add a Display Text action right after you assign new_entry to display its value—my guess is that it's not actually a proper path for use in Terminal.

-rob.

1 Like

These actions:

image

...appear to be targeting the Finder to get the path to the selected PDF (although I'm not sure how they are doing it!).

I'm finding that with macOS 15.whatever copied paths are coming through single-quoted, eg

'/Users/nigel/Desktop/For Forum/Weekly Changing URL v2.kmmacros.png'

...and you have to strip those quotes to use the path in a double-quoted KM shell variable (or keep them and escape any spaces). For example:

image

Here’s what I’m getting.

I am targeting QSpace Pro, a Finder replacement. It just right-clicks on the file and copies the path. (Copy Path is an option in the context menu.) It doesn’t appear to have the single quote marks.

Yep, my apologies, @michaelhyatt, I didn't develop that idea beyond the "pseudocode" phase.

1 Like

Good -- one less thing to worry about!

But I think you are missing an argument in your shell command. @kevinb's line contains:

...-o combined_new combined_old new_entry

...and I don't know what happens when an argument is missing.

It looks like you can't overwrite the old file with the new, so you'll have to create a new version and then Trash the old and remake the new with standard KM actions. So the shell script will be:

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/MacOS/join -o "$KMVAR_combined_new" "$KMVAR_combined_old" "$KMVAR_new_entry"

...and the actions required:

image

Edit to add:

One note of caution -- in reading up on this I found mention that combing PDFs this way can delete any links, eg to web pages. If Day One exports PDFs with links and those links are important to you then you'll want to find another method of combining them.

1 Like

Thanks. I appreciate you working through this with me.

Unfortunately, that doesn’t seem to work. It seems that the new entry is overwriting everything in the existing file.

It's working fine here, albeit with a limited number of actions cribbed from your full macro.

Check that you have your paths exactly right, and the same for the variables in your "Execute Shell Script" action. Check the pop-up menu to the left of your Shell Script action's text field and make sure you are including all 3 variables (or "All variables", as here):

image

I do have “Include All Variables.” I copied and pasted the shell script from your comment above:

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/MacOS/join -o "$KMVAR_combined_new" "$KMVAR_combined_old" "$KMVAR_new_entry"

Are there supposed to be three variables? The first two are the same.

There are supposed to be three -- the first has the same value as the second but with "-1" appended. Did you include this action before the Shell Script action?

image

If you replace your current shell script with this:

image

...you should get something like the following:

...where the first line will be the (temporary path of) the new combined file, the second line is the original PDF, the third the new PDF you want to add.

That’s working! Thanks.