i want to compress all my pdf files in an given directory and its sub-directories using ghostscript.
I´m stuck using the
find command within loops by filename including spaces.
Here some example code I´m aiming for:
pdffiles=$(find /path/to/directory -type f -name *.pdf) for file in pdffiles; do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -dQUIET -sOutputFile=new_$file $file; rm $file; mv new_$file $file; done;
Any idea how i could fix the problem with the spaces? Is there a better way to do this?