#!/bin/bash # For this script ghostscript package is needed. either install it or download static compiled binary for it. echo "This script will Compress all pdf files with prefix Compressed-" echo "do you wish to run the script (y/N)" read ans if [[ $ans == y ]] || [[ $ans == Y ]] then for i in *.pdf ;do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=Compressed-$i $i done else echo Exiting.. fi