Skip to content

Instantly share code, notes, and snippets.

@blizzz
Created October 26, 2016 15:49
Show Gist options
  • Save blizzz/8e3bc88c9a0dc2db40c79b0eaa4281ef to your computer and use it in GitHub Desktop.
Save blizzz/8e3bc88c9a0dc2db40c79b0eaa4281ef to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "split pdf to single pages"
echo "Usage:"
echo "$0 Inputfile Outputtrunk"
echo "Example:"
echo "\"$0 input.pdf out-\" results in out-1.pdf, out-2.pdf .. out-n.pdf"
exit
fi
ORIGINAL=$1
OUTPUTTRUNK=$2
PAGES=`qpdf --show-npages "$ORIGINAL"`
I=1
while [ "$I" -le "$PAGES" ];
do
qpdf "$ORIGINAL" --pages "$ORIGINAL" "$I"-"$I" -- "$OUTPUTTRUNK[$I].pdf"
let I=I+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment