Bulk Unlock PDFs on macOS: remove PDF password

Bulk Unlock PDFs on macOS: remove PDF password

Unlocking (removing passwords from) many PDFs on macOS is sadly not a built-in thing, it can be done with a simple app you can get via homebrew: qpdf.

This homebrew app will let you remove a password from a PDF.

👾
The big caveat here is: you must know the password.

This is great in use cases such as, as in our case, your CPA sends you your full set of tax documented encrypted with a password. Decrypting and them each time is a pain, and I like to archive things on my local NAS. Thus, I wanted a way to bulk remove passwords from the files, so I can put it into my document storage system.

Install qpdf

To install the little app, simply use Homebrew to get it:

brew install qpdf

🍑
If you're not a fan of Homebrew, you can also use Ports:

Alternative install instructions: sudo port install qpdf

Why qpdf

Simple: it has a PDF decrypt option in the command line. Moreover, it's free. The only personal hiccup I have is using the passwords on the command line itself. But otherwise, I rather like this little app.

Example single file usage

qpdf has a --decrypt option which, as the name states: will decrypt a given PDF with the given password.

The password is added using the --password option.

Command structure

The simplest way to use qpdf is by following the simple command line structure:

qpdf --decrypt --password=xxxxx encrypted-filename.pdf decrypted-filename.pdf

That will unlock one file (encrypted-filename.pdf) and save a copy of the PDF to the unlocked (no password) PDF file (decrypted-filename.pdf). Of course, in real usage use your actual file names. I don't think the output (decrypted file) file path is required, and if you leave it out, it should use the same filename as the encrypted one. I like to control the naming format, so I use both input and output names. :)

Bulk unlock / bulk password remove

This is done thanks to the find command line app. Below is the command to use.

find . -type f -name "*.pdf" -exec qpdf --decrypt --password=XXXXX {} {}.decrypted.pdf \;

find command explanation

As the name states, the find command finds things given certain parameters and, in our case, can act upon each individual file it finds.

We tell the find command to find only files, that have the PDF extension and to the pass that file name it found to qpdf with the filename as a parameter.

file <<= the command
. <<== here, in this current folder I am in
-type f <<== files only
-name "*.pdf" <<== files with a name that has anything infront of .pdf, thus find PDF files
-exec <<== do a command
{} <<== this curly open and close is where it passes the file name it found (per each file) to the command

How to manually remove password from a single PDF

Open the PDF in Preview, a browser, or another app (that can open PDFs), and go to File → Save As or File → Export and save as PDF as a new file.

Great! Next, complete checkout for full access to Piotr Krzyzek.
Welcome back! You've successfully signed in.
You've successfully subscribed to Piotr Krzyzek.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.