Regex Macros Misfiring on first try, working on 2nd

Hi there, I've got a couple different regex macros that have started doing this. Stumped as to what the cause could be. Any suggestions? I'll share the other macro in a subsequent post below.
More detail— The macro either does nothing on the first try (doesn't fail/abort), or will do just some (seemingly one) of the actions in the macro, though I haven't noticed any pattern about which action this is— When it partially executes like this it doesn't seem to be the same part each time. I then try triggering the macro again, and it works.

Other macro that does this: Format Book Title

Format Book Title.kmmacros (7.4 KB)

Yep, several:

  1. When you post an image of your Macro, please resize the panel in the editor to barely cover the width of the text of the Actions. Then make the image copy to post.
    • This will greatly help readability in the Forum, in most cases we will be able to read the image without clicking on it at all
    • I have to click on your image twice to read it all, and then I can see only 3-4 Actions on my large 27-in monitor.
  2. In the case of a long and complex macro, especially one about RegEx, it is much better to post:
    • Source string you want to match (use the Code Block)
    • The RegEx pattern you have
    • The desired result, also in a Code Block
    • An image of just the Regex Action where it fails.

Based on what you posted, we have no way to debug your RegEx.

If you'd like to post the info requested above, I'll take a look at it.

Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?


Thank you for offering to debug this Michael, but all I was hoping for was to be pointed in a direction to the effect of 'here are some generic reasons a regex macro might do nothing sometimes but work other times on the same text.' Would that be alright?

In your second macro, using the Finder to insert the renamed file name manually may be slowing the macro down or preventing it from working consistently. It's better to "move" (i.e. rename) a file in KM using File Actions. In your first macro, it's probably because the clipboard hasn't changed by the point that the macro is searching it, since just typing C doesn't mean the clipboard changes instantly. Try replacing the Type ⌘C action with KM's built-in Copy action, which waits for the clipboard to change before proceeding, and see if that doesn't help.


Thank you so much gglick! Both suggestions were bullseye's, AND your suggestion for the book title macro even solved another problem I hadn't yet asked about– The ability to apply the macro to multiple selected ebook files with one command. Thank you!

1 Like