Last active
November 18, 2018 15:15
-
-
Save janosh/62f4a4bf01627814c12a862a20338a63 to your computer and use it in GitHub Desktop.
Bash script, accepts directory as single argument, recursively compresses all PDFs in there and subdirectories, uses ghostscript, appends -min to name of compressed file
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
#!/bin/bash | |
find "$1" -name "*.pdf" | while read file; do | |
path=${file%/*} | |
basename=${file##*/} | |
ext=${basename##*.} | |
filename=${basename%.*} | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dQUIET -sOutputFile="$path/$filename-min.pdf" "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment