daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 20th, 2012 32 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/bin/bash
  2.  
  3. # First we remove the pdfmarks file, since we'll be building it from scratch
  4. rm pdfmarks
  5. rm      
  6.  
  7. # ChapterNumber is simple the number of the chapter, one chapter per pdf
  8. ChapterNumber=0
  9. NumberOfPages=1
  10.  
  11. # This loops over all the pdf files in the current directory
  12. for f in $(ls *.pdf)
  13. do
  14.         # We add one to the chapter number
  15.         ChapterNumber=$(($ChapterNumber+1))
  16.         # And we print this weird line into our pdfmarks file
  17.         echo "[/Title (Chapter $ChapterNumber) /Page $NumberOfPages /OUT pdfmark" >> pdfmarks
  18.  
  19.         # We get the number of pages from a small utility called pdfinfo, check if it's installed
  20.         # We add the number of pages in the current file to the NumberOfPages counter
  21.         NumberOfPages=$(($NumberOfPages + $(pdfinfo $f | grep -i "Pages:" | awk '{print $2}') ))
  22.  
  23.         # now we're finished with this file.. on to the next
  24. done
  25.  
  26. gs -dBATCH -dNOPAUSE -sPAPERSIZE=a4 -sDEVICE=pdfwrite -sOutputFile="MASTER.pdf" $(ls *.pdf) pdfmarks
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top