Batch resize folder of images to 3 pre-set sizes

Thanks to the brilliant advice and warm welcome I received on this forum earlier this week, I thought I’d venture to ask another [stupid] question.

After reading the KBM support docs and browsing this forum for hours, I have spent the past 2 days trying to cobble together a rather complex (to me at least) macro that would resize a number of images to 3 different sizes while keeping a copy of the original. In my mind, the pseudo steps to do this would be:

  1. Act on the selected files in Finder.
  2. First duplicate the original file and rename it to something like “[FileName] - Master”.
  3. Then resize the copied image to 157x157 and save it as something like [FileName] - 157x157 (sm).
  4. Then resize another copy of the same image file to 400x400 and save it as something like [FileName] - 400x400 (md).
  5. Then resize another copy of the same image file to 510x999 and save it as something like [FileName] - 510x999 (lg).

An absolute bonus would be if I were able to input the various image sizes (sm/md/lg) at runtime but I’m not sure if this would be possible. Another bonus would be if I were able to send all 3 images to the OptImage app for compression but again, I’m not sure if this is possible.

I do have the macro I have tried to hack together from the valuable contributions to similar posts on this forum and my own feeble attempts but I’d be too embarrassed to post it, to be honest. Is there anyone who would be willing to walk me through the steps of how to put something like this together? I’d like to use it as a learning experience so that I can apply the knowledge to building other macros.

Any help would be appreciated, even if it is only “Sod off, go RTFM!” :slight_smile:


Actually, you have a fairly complex question/requirement.

So, I assume you have done a forum search for keywords like image resize. If not, you might take a look.

Thanks for posting your workflow steps. That is always very helpful.
However, if you already have a macro, even if it is partially complete, it would be best for you to post the macro, and ask specific questions where the macro is not working as you would like.

From my quick look as the Search results for “image resize”, it appears there are several topics/macros that are similar to yours. See if you can use or adapt the Actions in those macros. If you have questions about any of them, then it is probably best to post in the thread where the macro is discussed.

No need to be embarrassed. Any macro that gets the job done is fine. It will save us and you time if you will post your macro, and ask specific questions about it. That way we will know where to help you.


1 Like

Hi @JMichaelTX,

thank you so much for taking the time to provide detailed feedback and advice, I appreciate it tremendously.

I have indeed searched the forums for image resize and tried to adapt the solutions proffered on those posts for my own purpose. I fear that I may be at that painful point of “not knowing what I don’t know” i.e. I know what I would like to achieve but I am not sure how to bend the KBM actions to my will and I don’t yet fully understand each of the macro steps I am trying to use. I realize that I still have lots of reading to do if I am to figure this out.

I take note of your suggestion to post my macro, even if I am embarrassed by it. I shall do so tomorrow after I have cleaned it up a bit (it is close to midnight over here now).

I shall also read the links you helpfully provided.

Thanks again for the reply!

Because you have broken the steps down, what you want to do is relatively straight forward.

Use a For Each action to iterate through the Finder Selection. That will give you the path of each file.

Use the Prompt for User Input action to ask for the desired sizes.

Use the Read a File action to read the image into a named clipboard.

Use the Resize Image action to resize the image. Use the variables you read in the Prompt For User Input action here to adjust the size as desired.

Use the Get File Attribute action to get the parent path and base name of the file path, so you can construct the file destination path.

Use the Write to a File action to write the image to the new file.

Perhaps use the Open a File action to open the file with OptImage, depending on how it behaves.

Repeat for the other three sizes.

Rename the original file.

Because you are messing around with batch file conversion, if things go wrong, they could go very badly wrong so make sure your backup system is complete, functional, and verified before starting on anything like this.


Hi @peternlewis,

thanks so much for the advice, that is really useful!

I am stuck on the “Prompt for User Action” though. While I have figured out how to write the value to the variable, I cannot figure out how to send that variable to the Resize Image step. Is there an option on that Action that allows me to use the value the user entered that I am missing somehow?

Thanks again for being so helpful.

All(most all) numeric Text Fields in Keyboard Maestro can expand to take a calculation as well - just start typing the variable name in to the Resize Image fields.

The (almost) only case where calculations are not allowed are triggers because triggers have to have fixed values, not changeable over time.

1 Like