Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将当前目录中的所有 jpg(独立于小写或大写或 jpeg 扩展名)转换为 95% 优化的文件。但是,我没有在我的 for 循环中正确获取 JPG、jpg 和 jpeg 文件的文件:/
#!/bin/bash PIC=$(ls "$PWD"/*.{jpg,jpeg,JPG}) for i in $PIC do echo $i # convert $i -quality 95 ${i%.*}_resaved.jpg done
尝试:
find -iname "*.jpg" -o -iname "*.jpeg" | while read f; do echo "$f" convert "$f" -quality 95 "${f%.*}_resaved.jpg" done