Want more features on Pastebin? Sign Up, it's FREE!
Guest

reorder4booklet2 (shuffle for 2up impose) USABLE IN PIPES

By: dingodog on Sep 23rd, 2011  |  syntax: Bash  |  size: 0.91 KB  |  views: 209  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. #simple script to get range of pages to use for reordering pages in a pdf and passing as argument to another pdf editing program (like pdftk), in order to impose as booklet with another program like Multivalent Impose tool. version intended to be usable in pipes
  3. #
  4. #usage: reorder4booklet2 number of pages
  5. #
  6. #number of pages must be a multiple of 4 or script will exit
  7. #
  8. #example: pdftk file.pdf cat `reorder4booklet2 40` output outputfile.pdf
  9. #
  10. #and *reorder4booklet2 40* will produce this output range: 40 1  2 39 38 3  4 37 36 5  6 35 34 7  8 33 32 9  10 31 30 11  12 29 28 13  14 27 26 15  16 25 24 17  18 23 22 19  20 21
  11. #
  12. #!/bin/sh
  13. tot=$1
  14. if [ $(( $tot % 4 )) -eq 0 ]
  15.         then
  16. tot4="`let DIVISION=$tot/2; echo $DIVISION`"
  17. for ((x=$tot, y=1;x>=$tot4, y<=tot4;x--, y++)); do echo "$x $y "; done | awk '{ print ; getline ; print $2, $1 }' | tr '\n' ' '
  18.         else
  19. echo " $tot is not a multiple of 4"
  20. fi
  21. exit
clone this paste RAW Paste Data