Created
April 23, 2024 20:53
-
-
Save taylorpaul/7dbb2c2255641d7ca5588cf067ae60f2 to your computer and use it in GitHub Desktop.
Bash Script (using pdftk) to Rip Last Page of PDF into seperate PDF and then merge all together.
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 | |
OUTDIR="./first_pass_notes" | |
OUTFILE="$OUTDIR/first-passes.pdf" | |
# Create the directory (ignore if already exitsing): | |
mkdir -p $OUTDIR | |
# Iterate through the PDF files and print the last page to our document | |
find . -maxdepth 1 -name "*.pdf" | while read fname ; do | |
echo "Working: $fname"; | |
pdftk $fname cat r1 output $OUTDIR/first-pass-$(basename $fname); | |
done; | |
# merge all those PDFs together | |
pdftk $OUTDIR/*.pdf cat output $OUTFILE | |
# Delete all those extra pdfs if you don't want them: | |
rm $OUTDIR/first-pass-*.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment