Skip to content

Instantly share code, notes, and snippets.

@s4parke
Last active September 27, 2022 15:37
Show Gist options
  • Save s4parke/acaed3d8327f13273d6027d770076c97 to your computer and use it in GitHub Desktop.
Save s4parke/acaed3d8327f13273d6027d770076c97 to your computer and use it in GitHub Desktop.
qpdf bash script to remove PDF passwords
--password=THISISTHEPDFPASSWORD
#!/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