diff options
-rwxr-xr-x | pdfdouble | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pdfdouble b/pdfdouble new file mode 100755 index 0000000..38ef116 --- /dev/null +++ b/pdfdouble @@ -0,0 +1,29 @@ +#!/bin/sh + +in="$1" +if [ -z "$in" ] || ! [ -f "$in" ] +then + echo Provide an input PDF. + return +fi + +s() { + seq $1 -2 $2 | tr '\n' ',' | sed -e 's/,$//' +} +pages=$(mutool info "$in" | grep '^Pages: ' | sed -e 's/.* //') +base="${in%.*}" +if [ $((pages % 2)) -eq 0 ] +then + echo Even + mutool draw -o "$base"-e.pdf "$in" $(s $pages 2) + mutool draw -o "$base"-o.pdf "$in" $(s $((pages - 1)) 1) +else + mutool draw -o "$base"-e.pdf "$in" $(s $((pages - 1)) 2) + mutool draw -o "$base"-o.pdf "$in" $(s $pages 1) +fi + +echo ' +1. Print odd. They may be more odd pages than even, + but not more even than odd. +2. Flip. +3. Print even.' |