bash script *.{jpg,jpeg}

It’s gona be compilacted…

I’m writing a bash script wich resizes all the images in a given directory. I need to select all the files with jpg, jpeg, JPG, JPEG etc. extensions, but i don’t know how.

source="$1/*.jpg" 

is working for the jpg extensions, but how can I add the others?
( $1 is a directory given as argument )

I was thinking of

source="$1/*.{jpg,jpeg}"

but doesn’t work

Can somebody help with this please?

The problem is that the quotes suppress brace expansion and when $source is substituted, it’s too late. Either:

source="$1/.jpg $1/.jpeg"

or don’t use $source but put the brace list in the expression directly, e.g.

for i in $1/*.{jpg,jpeg}
do

done

You need a GUI for that? Try out Baires Baires download which I provide in my repo, see signature for repo link

find $1 -iregex “..jpeg” -exec <yourCommand> “{}” “;”