Skip to content

Instantly share code, notes, and snippets.

@HyShai
Last active August 29, 2015 14:10
Show Gist options
  • Save HyShai/562f09041d1234022d43 to your computer and use it in GitHub Desktop.
Save HyShai/562f09041d1234022d43 to your computer and use it in GitHub Desktop.
Split pdf into multiple files
#!/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