Adding PDFs to Books app automatically?

Does anyone know if there is a way to add a PDF file into the Books app on macOS via script/automation etc?

I’ve subscribed to a local society who provide content in downloadable PDFs. From iOS/iPadOS it’s not difficult to open a PDF directly in Books, but on macOS it seems like you can’t do this in one step — it has to be downloaded and then “share” it to Books. Hazel can spot the files by their download URL but I can find no way to send them to Books.

Have you tried using open in bash/zsh? I’m not at my Mac but I’d try

Open -a “Books.app” filename.pdf

Well that does work. It launched the Books app and the PDF into a Preview window, at which point it is in my library. Just not ideal from a UX perspective. I see some more flags on open so I will have a play.

1 Like

If nothing else, you can use -g to get it to open in the background

This solution works too with AppleScript: open the file with Books and it will be added to your library - but open as well in Preview.

You could wrap it up in an Automator action…

It’s still going to launch the two apps, and while the -g flag stops an already running app from coming to the foreground if it has to launch Books it comes up in the foreground and regardless of that. Preview always opens in the foreground.

I think I will just stick with Hazel doing a rename of the files (when I can get that working) and manually dragging them into Books.

Have you looked at Doug's AppleScripts Books Archives » Doug's AppleScripts ?

Ooh, thanks! That does look interesting.