GS:制作递归脚本 [英] GS: Make recursive script
本文介绍了GS:制作递归脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此脚本来调整一些用户上传到FTP的扫描pdf文件的大小.我需要的是减小pdf的大小,减少处理它们的时间(上传到s3等).
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).
脚本:
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.
谢谢.
推荐答案
您的脚本不是脚本.这是一个命令行.
Your script is not a script. It is a command line.
您可以编写一个Shell脚本来遍历文件夹中的所有* .pdf文件,然后为每个文件调用gs ...
.
You could write a shell script to iterate over all *.pdf files in the folder, and then call gs ...
for each.
类似这样的东西:
#!/bin/bash
for f in *.pdf
do
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=processed/$f $f
done
这篇关于GS:制作递归脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文