projects
/
cmccabe-bin
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
fa4183d
)
Add remove-pdf-password.sh
author
Colin P. Mccabe
<colin@cmccabe.xyz>
Thu, 22 Jul 2021 23:28:54 +0000 (16:28 -0700)
committer
Colin P. Mccabe
<colin@cmccabe.xyz>
Thu, 22 Jul 2021 23:28:54 +0000 (16:28 -0700)
remove-pdf-password.sh
[new file with mode: 0755]
patch
|
blob
diff --git a/remove-pdf-password.sh
b/remove-pdf-password.sh
new file mode 100755
(executable)
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"