Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- # First we remove the pdfmarks file, since we'll be building it from scratch
- rm pdfmarks
- # ChapterNumber is simple the number of the chapter, one chapter per pdf
- ChapterNumber=0
- NumberOfPages=1
- # This loops over all the pdf files in the current directory
- for f in $(ls *.pdf)
- do
- # We add one to the chapter number
- ChapterNumber=$(($ChapterNumber+1))
- # And we print this weird line into our pdfmarks file
- echo "[/Title (Chapter $ChapterNumber) /Page $NumberOfPages /OUT pdfmark" >> pdfmarks
- # We get the number of pages from a small utility called pdfinfo, check if it's installed
- # We add the number of pages in the current file to the NumberOfPages counter
- NumberOfPages=$(($NumberOfPages + $(pdfinfo $f | grep -i "Pages:" | awk '{print $2}') ))
- # now we're finished with this file.. on to the next
- done
- gs -dBATCH -dNOPAUSE -sPAPERSIZE=a4 -sDEVICE=pdfwrite -sOutputFile="MASTER.pdf" $(ls *.pdf) pdfmarks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement