Skip to content

Instantly share code, notes, and snippets.

@TiloGit
Created December 3, 2022 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiloGit/588a4bf3a0c5d2dbf6691604eafe838c to your computer and use it in GitHub Desktop.
Save TiloGit/588a4bf3a0c5d2dbf6691604eafe838c to your computer and use it in GitHub Desktop.
compress and rename shaw PDFs
##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
@TiloGit
Copy link
Author

TiloGit commented Dec 3, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment