Ubuntu隐蔽文件夹中的所有图像 [英] Ubuntu covert all images in a folder
问题描述
我正在使用脚本将文件夹中的所有图像转换为翻牌操作.脚本是这样的:
I am using a script for converting all the images in my folder to flop operation. The script is like this:
for f in *.jpg; do
new="${f%%.jpg}_flop.jpg";
convert "$f" -flop -quality 100 "$new";
done
现在我发现可能还存在扩展名为.JPG
的图像,我想添加一个新的for循环,如下所示:
Now I have found that there may be also images with the extension .JPG
I thought of adding a new for loop that looks like this:
for f in *.JPG; do
new="${f%%.jpg}_flop.jpg";
convert "$f" -flop -quality 100 "$new";
done
我认为有一种忽略大小写的语法,这样我可以做一个单循环而不是2,有什么帮助吗?
I think that there is a syntax for ignoring the case, and this way I can do a single loop instead of 2, any help?
更多,如果还会有扩展名.jpeg
或.JPEG
,是否也有相应的语法?
More, if there will also be the extensions .jpeg
or .JPEG
, is there a syntax for this, too?
推荐答案
您可以轻松完成
for f in *.jpg *.JPG; do
...
如果您要使用单个表达式,则可以使用 extglob
在Bash中的扩展名.
If you want a single expression, you can use the extglob
extension in Bash.
set -o extglob
for f in *.@(JP@(|E)G|jp@(|e)g); do
...
要使对大小写不敏感,您可以 shopt -s nocaseglob
,但是没有使单个glob表达式不区分大小写的特殊语法.
To make globbing case insensitive, you can shopt -s nocaseglob
but there is no particular syntax to make a single glob expression case-insensitive.
您也可以使用稍不精确的
You could also use the slightly imprecise
for f in *.[Jj][Pp][Gg] *.[Jj][Pp][Ee][Gg]; do
...
不区分大小写地匹配.
这篇关于Ubuntu隐蔽文件夹中的所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!