Someone sent me a bunch of BMP files and I need them in JPEG. I could convert them one by one using GIMP, but I'd rather do it all in one go. I have Ubuntu.

6 Answers 6


You can use ImageMagick's mogrify tool

mogrify -format jpg *.bmp
  • 3
    Note that this answer works for Windows too, as ImageMagick is available to download for Windows as well.
    – Gnoupi
    Oct 24, 2009 at 6:57
  • 1
    It's sudo apt install imagemagick on Ubuntu and you can set the quality by adding -quality 100
    – mpen
    Sep 2, 2017 at 17:36

You are likely to have ImageMagick installed on Ubuntu.
That can do,

convert filename.bmp filename.jpg


The mogrify (answered by hyperslug and referred by cjm) is also a good option.

Use the mogrify program to resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
This tool is similiar to convert except that the original image file is overwritten
(unless you change the file suffix with the -format option) with any changes you request.

  • 1
    ImageMagick's mogrify command is better than convert for this, because it can be used easily with wildcards. See hyperslug's answer.
    – cjm
    Aug 21, 2009 at 5:28

Let me do a little change to salmonmoose answer:

for i in `ls *.bmp`; do convert $i $i.jpg; done

The above works but generates files named "bmp.jpg". You can get .jpg files with this command:

for i in *.bmp; do convert ${i} ${i%bmp}jpg; done

See man bash for details of the for command. The ${i%bmp} part means the string "${i}" without the "bmp" substring at the end.

There are other operations to transform the string in "${i}". "$i" is a shorthand for "${i}". The ls *.bmp part in salmonmoose answer means "execute ls *.bmp, then the for i part assigns each string separated by spaces to i". The same is achieved by *.bmp because it matches all file names in the directory.

There is a drawback with for - if the files in your directory have spaces in the name, for example "wedding picture 1.bmp", it will be assigned 3 times to the i var, performing these commands:

convert wedding wedding.jpg 
convert picture picture.jpg
convert 1.bmp  1.bmp.jpg

In my answer also the match "${i%bmp}" fails.

But there is a solution - you can use the find command instead. See man find for details. You should type something like the following (please check the syntax with the man page before trying it):

find -name *.bmp -type f -exec convert '{}' '{}'.jpg \;

(I am not very sure of the name part, and I have some doubt in the -exec part, see man find first)

If you want to join all the images in one .jpg file, you can concatenate them with other filter, as the one mentioned in the first answer.

  • This fails on files containing a space in the name so would be more robust if quoted i.e. for i in *.bmp; do convert "${i}" "${i%bmp}jpg"; done
    – Adam B
    Jul 20, 2020 at 12:49
for i in `ls *.bmp`; do convert $i $i.jpg; done

Yes, this will make a bunch of files called filename.bmp.jpg but it'll do the job.


Convert .bmp to .jpg using Linux:

for ii in *bmp;do base=`echo $ii|cut -d"." -f1`; convert $ii $base.jpg;done


foo2.bmp becomes foo2.jpg

Recursive using find and ImageMagick's mogrify:

find . -iname *.bmp -exec mogrify -format png "{}" \;

The bmp files will remain in place.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .