Tianxiang Xiong
Tianxiang Xiong

Reputation: 4081

Convert multiple images in Imagemagick (Windows)

I'm trying to convert multiple .tif files into .png files using Imagemagick on the Windows command line. I tried the following, which didn't work:

convert -format tif *.png

I then tried a loop

for %a in (*.tif) do convert %a %a.png

which did work but now all my images are named as [something].tif.png, which is annoying.

So why didn't the first command work, and if there's no way to get the first command to work, is there a way to improve the second command so I won't have to deal with the .tif in the .png image name?

Edit It seems that I got the first command wrong. First of all, convert doesn't work but mogrify does. I had read that mogrify replaced the files of the old format, but apparently it isn't true because it created new images for me without deleting the old ones. Secondly, it seems that the destination file type comes first, so the command is

mogrify png *.tif

which works perfectly.

I'd still like to know how the second command could be improved.

Upvotes: 12

Views: 12890

Answers (1)

Zsolt Botykai
Zsolt Botykai

Reputation: 51583

Why don't you use mogrify?

mogrify -format tif *.png

will create 1.tif from 1.png ... N.tif from N.png.

Upvotes: 17

Related Questions