0

I'll try to make this as short as possible.

I have a folder that contains 9000 images (almost). But the extension of these images is png. I would like to change the extension of all these images in one command so they all become .jpg

If someone knows a way to do that can you please share it?

Thank you for your help.

  • A quick google gave me this: https://robservatory.com/use-sips-to-quickly-easily-and-freely-convert-image-files/. Perhaps that is something you can try? I suggest doing a backup or at least try on a subset of your image files before converting all. – mattias Nov 11 '17 at 17:30
  • 1
    You cannot just edit the extensions. Many tools will not like to have a .jpg suffix on an actual PNG image. So you should find a tool such and ImageMagick that will actually convert the file to the new format and change the suffix appropriately. Look below for the suggestion from Tim Howland to use mogrify in ImageMagick. It will process a whole folder at once. See http://www.imagemagick.org/Usage/basics/#mogrify. P.S. for other renaming edits other than the suffix, I use NameChanger on my Mac Sierra. – fmw42 Nov 11 '17 at 18:51

2 Answers2

3

If they are PNG images that you are trying to turn into jpgs, I'd recommend installing Imagemagick (via homebrew), and using the "mogrify" command to change them (see https://www.imagemagick.org/script/mogrify.php):

magick mogrify -format jpg *.png

If they are all actually jpegs, and you've ended up with the wrong file extension, you can do something like:

ls | grep \.png$ | sed 'p;s/\.png/\.jpg/' | xargs -n2 mv

See: Batch renaming files in command line and Xargs (even though it's linux, these tools are all available in the OSX default install)

Tim Howland
  • 7,919
  • 4
  • 28
  • 46
  • What can I do if I want to delete png files while turn into jpg? In windows I can use ¨ren *.png *.jpg¨ – dasmehdix Mar 11 '22 at 08:31
0

I did it by using a virtual machine (Windows) In the cmd I used this command : ren *.* *.jpg and it worked. Although I guess on Mac it's a bit harder.