GS: Make recursive script

血红的双手。 提交于 2019-12-12 01:37:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!