Skip to content

Instantly share code, notes, and snippets.

@mat813

mat813/shuffle.sh

Created Apr 10, 2015
Embed
What would you like to do?
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