Last active
August 29, 2015 14:10
-
-
Save HyShai/562f09041d1234022d43 to your computer and use it in GitHub Desktop.
Split pdf into multiple files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
page_count=`pdfinfo $1 | grep Pages: | cut -d':' -f2 | tr -d ' '` | |
pages_per=10 | |
i=1 | |
while [[ $i -le $page_count ]]; do | |
echo $(( $i + 10 )) | |
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=$i -dLastPage=$(( $i + $pages_per )) -sOutputFile=output2$i.pdf $1 | |
i=$(( $i + $pages_per )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment