【发布时间】:2015-01-30 02:37:11
【问题描述】:
我需要使用 pnmtojpeg 将几个 pnm 图像文件转换为 jpeg。所以我使用了这个脚本,我将其命名为“pnm2jpg”:
for f in *.pnm;
do pnmtojpeg -quality=85 "$f" > "${f%.pnm}.jpg";
done
这很好用。但是,我想进一步调整它,以便它也可以用于单个文件。
也就是说,如果命令行中没有指定文件,则处理所有文件。
$ pnm2jpg thisfile.pnm # Process only this file.
$ pnm2jpg # Process all pnm files in the current directory.
非常感谢您的洞察力-谢谢。
【问题讨论】:
标签: bash shell scripting command