Last active
June 8, 2022 06:13
-
-
Save bserem/f3c410a724cd08b553a954b57ec67cdf to your computer and use it in GitHub Desktop.
Batch compress PDF files like invoices (especially made for timologio by AADE that produces huge 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
#! /bin/bash | |
for f in *.pdf | |
do | |
fbname=$(basename "$f" .pdf) | |
fbname_safe="${fbname// /_}" | |
mv "$fbname".pdf $fbname_safe.temp.pdf | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$fbname_safe.pdf $fbname_safe.temp.pdf | |
# To also change PDF title (untested): | |
# gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$fbname_safe.pdf $fbname_safe.temp.pdf -c "[ /Title (My New Title) /DOCINFO pdfmark" | |
rm $fbname_safe.temp.pdf | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment