Decrypt all PDF's in a Directory
I recently had to decrypt a bunch of PDF's. I knew the password, but didn't want to do them one at a time. Luckily, some quick scripting did the trick.
brew update && brew install qpdf
Fire up your favorite text editor (I named the file decrypt.sh
):
#!/bin/bashDECRYPTED_FOLDER="decrypted"mkdir $DECRYPTED_FOLDERfor f in *.pdfdoqpdf --decrypt --password="$1" "$f" "$DECRYPTED_FOLDER/$f"done
Give it some power: chmod +x decrypt.sh
Make sure the script is in the same directory as the PDF's you want to convert. It'll make a new directory called "decrypted" and dump the PDF's into it.
./decrypt.sh pdfPasswordHere
For example:
./decrypt.sh awesomesauce
Enjoy decrypting!