Search code examples
imagemagickjpegjpeg2000

Keep Same Filename When Converting Using ImageMagick


I'm trying to convert several hundred specifically named .jp2 files in a directory to .jpg files using ImageMagick from the terminal.

For example, I want A.jp2, B.jp2, C.jp2 to become A.jpg, B.jpg, C.jpg.

I tried the following command:

convert *.jp2 *.jpg

However, this gave me the following files:

  • *-0.jpg
  • *-1.jpg
  • *-2.jpg
  • etc.

How can I keep the names of the original files when I convert them?


Solution

  • Use the "mogrify" command

    mogrify -format jpg *.jp2