Bulk decrypt multiple PDF files

automatorencryptionpdf

I have received a selection of PDF files (about 40) that are all encrypted with the same password. I'd rather not have them be encrypted because it's annoying to enter the password every time and I already have full disk encryption anyways.

How can I decrypt all of these PDF files without having to manually open and re-save each and every file? I looked in Automator but I only found an option to Encrypt PDF, not Decrypt.

Best Answer

I'd use a third-party utility named qpdf that can be compiled from source, or installed via Homebrew, i.e.:

brew install qpdf

Then change directory to where the encrypted PDF files are, assuming they are in a directory by themselves, and use the following compound command, e.g.:

for f in *.[pP][dD][fF]; do qpdf --decrypt --password=password "${f}" "${f%.*}-decrypted.${f##*.}"; done