From 41ac0aba1a98718068d86f2934130fcfe70d5ea6 Mon Sep 17 00:00:00 2001 From: kaa Date: Thu, 25 Jul 2024 14:08:52 -0700 Subject: Public release. --- pdfdouble | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 pdfdouble 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.' -- cgit v1.2.3