X-Git-Url: http://www.club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?p=cmccabe-bin;a=blobdiff_plain;f=remove-pdf-password.sh;fp=remove-pdf-password.sh;h=79c8a6ec6a6a1f2df98f0735d1b4647a2a326315;hp=0000000000000000000000000000000000000000;hb=dbee9b8e02b9ac3e9d76886d8d8b4059204c5187;hpb=fa4183dd778e5e3a0ceeec14f7715e790982b6b6 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"