large PDF size (invoices) ; script to compress and rename

Tlow
Grasshopper

I posted long time ago in the old shaw forum why the invoice pdf is large and the date stamp in the filename is not useful for sorting. 

The downloaded PDF from shaw are very large (1.5 to 4 MB) I guess as the same files would be use for print out invoices. 

Anyhow here a linux script I used to reduce the size (compress images in invoice) and rename the output file might be useful for someone else. 

requires to install gs (ghostscript) on your linux system. I use this on WSL (Windows Linux Subsystem)

 

##for PDF invoices with filename like ShawInvoice_01412345678_01Apr2022.pdf
for file in Shaw*.pdf
do
echo "$(date +"%F_%s") Start $file"
filedate=$(basename "$file" .pdf | tail -c 10)
outFdate=$(date -d $filedate +"%F")
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/ebook -sOutputFile=${outFdate}_${file} $file
echo "$(date +"%F_%s") Done $file"
done

 

 

0 Kudos