Action Based on File Extension

I'm not a complete newbie to Keyboard Maestro. I've done dozens if macros: I'm a retired programmer. But I have done almost no file manipulation using it. I'm having trouble figuring out how this works. Here's what I want to do

  1. Manually Select one or more files in finder
  2. in KM, If the extension of the file is RTF, perform certain actions.

I cannot figure out how to get the extension of the file and test it as a condition in an IF statement. If someone could help me with that much, I think I can work out the rest.

1 Like

Hey Allen,

Good to see you here!  :sunglasses:

Here's a very simple example.

This kind of thing is easy, once you get used to the relevant actions.

Extract RTF Files From the Finder Selection v1.00.kmmacros (7.4 KB)

You can also use a filter to extract various parts of a path:

Filter action

Or you could use a regular expression:

Search Variable action

You could also use AppleScript:

Execute an AppleScript action

Extract RTF Files From the Finder Selection – AppleScript v1.00 .kmmacros (6.4 KB)

Holler at me if you need any more help.


Wow! Thank you for the extremely helpful response! No time today to try this out but I'll report back when I do.

1 Like