Shell – ImageMagick: multiple files conversion & saving with different name

filenamesimagemagickshellwildcards

I am creating a bash script. How can I perform a set of operations/transformations (of choice) on all .jpg images in a different directory using ImageMagick's convert utility ? The converted image should be named *-change.jpg

Here's my code:

convert $file/*.jpg -flip $file/*-change.jpg

Best Answer

You can set the output file name via -set + some percent escapes (in this case you need the directory component of the path %d and the file name without extension %t):

convert "${dir}"/*.jpg -flip -set filename:t '%d/%t-change' '%[filename:t].jpg'

I used t as a filename:property but really, you can use whatever you want...

Related Question