Skip to content

Instantly share code, notes, and snippets.

@mat813
Created April 10, 2015 10:39
Show Gist options
  • Save mat813/9c455be39622c1f9b138 to your computer and use it in GitHub Desktop.
Save mat813/9c455be39622c1f9b138 to your computer and use it in GitHub Desktop.
Use pdftk to shuffle even and reverse odd scanned pages in a single document
#!/bin/sh
if [ `expr $# % 2` -ne 0 ]
then
echo "odd number of arguments"
exit 1
fi
while [ $# -gt 0 ]
do
even=$1
odd=$2
shift 2
echo shuffling ${even} and ${odd}
pdftk A="${even}" B="${odd}" shuffle A Bend-1 output ${even%.pdf}-${odd}
mkdir -p "#recycle"
mv "${even}" "${odd}" "#recycle"/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment