Skip to content

Instantly share code, notes, and snippets.

@neulaender
Created April 19, 2017 21:40
Show Gist options
  • Save neulaender/4211944e8c09747042e3cf896c371289 to your computer and use it in GitHub Desktop.
Save neulaender/4211944e8c09747042e3cf896c371289 to your computer and use it in GitHub Desktop.
Compress PDFs in bash
# compress PDF. Needs ghostscript package.
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -DBATCH -sOutputFile=out.pdf in.pdf
# compress all PDFs in dir
for file in `ls *.pdf`;
do
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -DBATCH -sOutputFile=${$file%.pdf}-c.pdf $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment