Batch Convert JPG > PNG

This one feels so simple I feel like I am missing something.

Is there a way to Batch convert for all the files selected by Finder from JPG to PNG / and or PNG to JPG?

I made a macro that can change the extensions 1 file at a time but would love to be able to do a few at time.

I do use Name Manger 3 to rename lots of files at once but I am just looking for KM Macro that I can use to do about 4 to 5 at a time.

Does it need to be in KM?

OSX Automator can do it:

you can save it as a Service.

You can also call Automator workflows directly from KM:
Execute an Automator Workflow action.

1 Like

So I have yet to work with automator but if I can trigger it from KM that should be sufficient.

Thanks all!

Probably there are some command-line programs that will also do this type of conversion. Maybe one of the shell script gurus, like @tjluoma, will come along and offer some suggestions.

Converting from JPG to PNG is easy enough.

Given an input file "$i" all you need is:

/usr/bin/sips -s format png "${i}" --out "${i%jpg}png"

That will create a PNG with the same filename as the JPG except the jpg will be changed to png obviously.

Then it's just a matter of making a Keyboard Maestro macro for Finder to process the selected images.

1 Like

Thanks for the quick reply!

This is my first experience with a shell script so I know I am missing a step here just can't figure out what it is.

Resize JPEG Images.kmmacros (25.5 KB)

  1. When you use a Keyboard Maestro variable in a shell script, you have to preface it with $KMVAR_

  2. In my example, I use the variable i but you don't have anything that sets the variable i

I don't have the correct syntax handy and I'm not entirely sure what you're trying to do. Are you trying to read filenames from a file or from selected files in the Finder.

I just want to change the file types from JPG to PNG.

I spent about 15 minutes with automator today for the first time and was able to do achieve this pretty easily thanks to everyones help! Might spend some more time in here as it seems to be pretty powerful.

1 Like

Hi @Brian_Martin!

I am trying to do a similar task (although from Heic to Jpeg), would you be so kind to share your macro?

sips -s format jpeg "${i}" --out "${i%HEIC}jpg"


sips -s format jpeg "${i}" --out "${i%heic}jpg"

The first is used for when the suffix is uppercase. There's probably a way to combine these into one.


This thread helped me quite a bit but since there was no final solution, here's a working macro that I'm now using. Tweak as required of course but this one will:

  1. Monitor macOS Desktop folder for new screenshots
  2. Rename screenshot file to timestamp format for better sorting and renaming
  3. Convert PNG to JPG, for smaller filesize

I'm sure it can be optimized but it works fine despite a lot of steps. HTH someone.

Finder > Auto Rename Screenshots.kmmacros (6.9 KB)


if you want to use JPGs for screenshots, then tell macOS you want to use JPGs for screenshots.

Enter these two lines in Terminal:

defaults write type -string 'jpg'

killall SystemUIServer

The next time you take a screenshot, it should be in JPG instead of PNG.


Hi @tjluoma Im trying to do something similar to this changing all incoming pngs to jpgs but Im unsure of the syntax when used together with Keyboard Maestro variables. Can you still use the % to change file format on the output file?


Skjermbilde 2021-08-27 kl. 13.12.17

Also if I change change the image type with search replace it works, but the filename of the output file ends up in a crazy format. Like this:
10.08.202102514.png -> .10.08.202102514.jpg.60T39-vK0K

I almost always use external script files, so I’m not sure, but I think that when you use % in Keyboard Maestro’s editor, you might need to use %% so that Keyboard Maestro doesn’t try to interpret it as a Keyboard Maestro variable.

@tjluoma, I wanted to say a big, belated thank you for the JPG screenshot switch tip, that works perfectly. That allows me to save a bunch of steps in my "watch for screenshots" macro, and also helps with the screenshots to clipboard function of course. Cheers.


Thank you for taking the time to write. It's always nice to know that something I said was of actual use to someone. :smiley:


Information related to this topic was discussed on the Automators Talk forum. Here's the link for those that might be interested.

Use Hazel and Automator to convert image while retaining original - Automators Talk