Last active
September 27, 2022 15:37
-
-
Save s4parke/acaed3d8327f13273d6027d770076c97 to your computer and use it in GitHub Desktop.
qpdf bash script to remove PDF passwords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--password=THISISTHEPDFPASSWORD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use QPDF to remove the encryption on PDFs in with a password | |
# The script creates a decrypted copy of all PDFs in directory: decrypted.FILENAME.pdf | |
# 1. Requires a file called password.txt in the same location as the command | |
# with the following contents << | |
# --password=THISISTHEPDFPASSWORD | |
# 2. Requires qpdf (brew install qpdf on macos) | |
shopt -s nullglob | |
for f in *.pdf | |
do | |
echo "Removing password for pdf file - $f" | |
qpdf --decrypt @password.txt "$f" "decrypted.$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment