问题
Im using this script to resize some scaned pdf files that users upload to FTP. What i need is to reduce the size of pdf, to reduce the time to process them (upload to s3, etc).
The script:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
So my question is: How can i make this recursive? I need all files in the folder to be reduced. If this can overwrite the original file, then is perfect.
Thanks in advance.
回答1:
Your script is not a script. It is a command line.
You could write a shell script to iterate over all *.pdf files in the folder, and then call gs ...
for each.
Something like this:
#!/bin/bash
for f in *.pdf
do
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=processed/$f $f
done
来源:https://stackoverflow.com/questions/42557785/gs-make-recursive-script