Created
August 22, 2017 18:23
-
-
Save debuglevel/70cd86f923a909434ee0fc494539452a to your computer and use it in GitHub Desktop.
Bash script to merge multiple (possibly protected) PDFs
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 | |
# execute in a directory with the respective PDF files only | |
echo "Execute this script only if" | |
echo " 1. this directory contains only the PDF files you want to merge" | |
echo " 2. you have no problem that this script will rename them" | |
echo " 3. you downloaded them in their linear order (first chapter first; this tool is based on the creation date)" | |
read -rsp $'Press enter to continue or CRTL-C to abort...\n' | |
#qmv -t -r --format destination-only | |
for f in *.pdf | |
do | |
mv -n "$f" "$(date -r "$f" +"%Y%m%d_%H%M%S_$f")" | |
done | |
for i in *.pdf; do | |
echo | |
pdftk "$i" output "$i.unrestricted.pdf" allow AllFeatures | |
echo | |
#qpdf --decrypt "$i" "_$i" | |
done | |
pdftk *.unrestricted.pdf cat output output.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment