Created
April 21, 2018 06:37
-
-
Save k-nut/c6e20a0cef87e3a851af0c2a83ea2415 to your computer and use it in GitHub Desktop.
Turn a scanned duplex pdf [1,2,3,5,6,4] into the correct order [1,2,3,4,5,6]
This file contains 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/sh | |
FILENAME="$1" | |
COUNT=$(pdfinfo "$FILENAME" | awk '$1 == "Pages:" {print $2}') | |
HALF=$((COUNT/2)) | |
ARGUMENTS="" | |
for i in $(seq 1 $HALF) | |
do | |
ARGUMENTS="$ARGUMENTS Reorder-Page-$i.pdf" | |
done | |
for i in $(seq $COUNT -1 $((HALF+1))) | |
do | |
ARGUMENTS="$ARGUMENTS Reorder-Page-$i.pdf" | |
done | |
for i in $(seq 1 $COUNT) | |
do | |
pdfseparate -f $i -l $i "$FILENAME" "Reorder-Page-$i.pdf" | |
done | |
pdfunite $ARGUMENTS "$2" | |
rm Reorder-Page-* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment