Different Ways to Rename Macros

If you wanted to change every selected macro you can do it like this.

Add Text at End for All Selected Macros
tell application "Keyboard Maestro"
  set selectedMacrosList to get selectedMacros
  repeat with theMacro in selectedMacrosList
    set macroName to name of macro id theMacro
    if macroName does not end with "(available via Raycast)" then
      set name of macro id theMacro to (macroName & " (available via Raycast)")
    end if
  end repeat
end tell

If you wanted to toggle that from every selected macro you could do it like this.

Toggle Text at End for All Selected Macros
tell application "Keyboard Maestro"
  set selectedMacrosList to get selectedMacros
  repeat with theMacro in selectedMacrosList
    set macroName to name of macro id theMacro
    set searchText to " (available via Raycast)"
    
    if macroName ends with searchText then
      -- Remove the text if it is present
      set name of macro id theMacro to text 1 thru ((length of macroName) - (length of searchText)) of macroName
    else
      -- Add the text if it is not present
      set name of macro id theMacro to (macroName & searchText)
    end if
  end repeat
end tell

And to round it out if you wanted the text at the begnining of the macro names.

Toggle Text at Start for All Selected Macros
tell application "Keyboard Maestro"
  set selectedMacrosList to get selectedMacros
  set searchText to "(available via Raycast) " -- Now at the beginning
  
  repeat with theMacro in selectedMacrosList
    set macroName to name of macro id theMacro
    
    if macroName starts with searchText then
      -- Remove the text if it is already at the beginning
      set name of macro id theMacro to text ((length of searchText) + 1) thru -1 of macroName
    else
      -- Add the text at the beginning if it’s not already there
      set name of macro id theMacro to (searchText & macroName)
    end if
  end repeat
end tell

A of couple macros that you can use your own text via a user prompt to the start and end several macros.

With User Prompt

**AAA - Automation - Keyboard Maestro Macros.kmmacros (62 KB)


And here you can replace any text you want in the selected macros.

Search and Replace

Replace Text in Selected Macros

Text Replacement - Replace Text for All Selected Macros with Prompt.kmmacros (32 KB)


This macro will add numbers to the start of the selected macros in Keyboard Maestro editor, so if you don't want them to show up alphabetically in the conflict pallet, you can sort by some other method like date created, date modified or date used to then quickly add numbers for them to show up in that order in the conflict pallet (I absolutely love Keyboard Maestro's conflict pallet so much better than how you had to set that up back in the day in QuicKeys, thank you, Peter!)

Add Sequential Numbering at the Start of Each Macro in Keyboard Maestro Current Sort Order

Add Numbers In Current Sort Order

Text Replacement - Add Sequential Numbering at the Start of Each Macro in Keyboard Maestro Current Sort Order.kmmacros (30 KB)


This one was a bit more of a bear but what I prefer and do quite often for the conflict pallet. I like to use the numbers rather than the letters if I can to quickly get to a macro on the conflict pallet. This macro makes that pretty quick to make. Also, note that there is logic in the numbering if less than 11 are selected.

Add Numbers to Name 0 for 10th if Only 10

Zero for Tenth if Only 10

Text Replacement - Add Sequential Numbering at the Start of Each Macro in Keyboard Maestro Current Sort Order and Add Numbers in Conflict Pallet Display Name (If Just 10 the 10th is "0").kmmacros (32 KB)


If you don't like the 10th one being a zero if there is only 10 then here you go it will always add them. Also note that there is logic in the numbering if there is less than 10 selected.

Add a Number in the Name and Start 10 and Not 0 For 10th

Add a Number in the Name and Start 10 and Not 0 For 10th

Text Replacement - Add Sequential Numbering at the Start of Each Macro in Keyboard Maestro Current Sort Order and Add Numbers in Conflict Pallet Display Name.kmmacros (32 KB)


This macro allows you to remove numbers at the start of selected macros if you want to start over and renumber them in a different order. Use it in conjunction with "Add Sequential Numbering at the start of Each Macro"

Remove Sequential Numbering at the Start of Each Macro in Keyboard Maestro Macro

02)Text Replacement - (2) Remove Sequential Numbering at the Start of Each Macro in Keyboard Maestro.kmmacros (30 KB)

If you have new macros you have made like this one and want to quickly insert another action in the macro pallet quickly this is a great way to do it. Maybe when I am done I will compile all of these into one download.

Increment or Decrement All Numbers in Selected Macros By One

Increase All Numbers in Selected Macros By 1

**AAA - Automation - Keyboard Maestro Macros.kmmacros (63 KB)

If you want to keep your numbers safe if you have a sequential list and just add text to the start.

Toggle Text at Start for All Selected Macros with Prompt (Sequential Number Safe)

Toggle Text at Start for All Selected Macros with Prompt (Sequential Number Safe)

12)Text Replacement - (12) Toggle Text at Start for All Selected Macros with Prompt (Sequential Number Safe).kmmacros (32 KB)

Here you can add or remove padded zeros in the macro name that shows up in the conflict pallet.

Add or Remove Padded Zero to Number in Parenthesis

Remove and Add Padded Zero
**AAA - Automation - Keyboard Maestro Macros.kmmacros (84 KB)

Here is the whole bundle at once. Updated on 2025-03-19

**AAA - Automation - Keyboard Maestro Macros.kmmacros (895 KB)

Keyboard Maestro Export

4 Likes

Thank you for that. Maybe bulk macro renaming could be included in a future KM version.

1 Like