From: Colin P. Mccabe Date: Thu, 22 Jul 2021 23:28:54 +0000 (-0700) Subject: Add remove-pdf-password.sh X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbee9b8e02b9ac3e9d76886d8d8b4059204c5187;p=cmccabe-bin Add remove-pdf-password.sh --- diff --git a/remove-pdf-password.sh b/remove-pdf-password.sh new file mode 100755 index 0000000..79c8a6e --- /dev/null +++ b/remove-pdf-password.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +die() { + echo $@ + exit 1 +} + +[[ $# -eq 1 ]] || die "this script takes exactly one argument: the name of a pdf" +INPUT=$1 +INPUT_BASE=${INPUT%.pdf} +[[ -f "${INPUT}" ]] || die "input file ${INPUT} does not exist." +echo -n Password: +read -s PASSWORD +echo +exec qpdf -password="${PASSWORD}" -decrypt "${INPUT}" "${INPUT_BASE}.decrypted.pdf"