Macros: Backup Macros Before Tinkering (And Revert After You Hate the Changes)

I've been toying with KM8's AppleScript support and kludged together these two scripts to 1) backup and rename macros before tinkering with them and 2) revert to the original name when I'm ready to go back. I'm a novice with AppleScript so there are definitely cleaner ways, but here's a start:

1. [BU] Backup, Duplicate, and Disable Selected Macros Before Tinkering

Requires:

As @JMichaelTX always says:

Carefully review the Release Notes and the Macro Actions
Make sure you understand what the Macro will do.
You are responsible for running the Macro, not me. :wink:

Download: [BU] Backup, Duplicate, and Disable Selected Macros Before Tinkering.kmmacros (27.9 KB)


2. [BU] Revert to Original File Name and Re-Enable Selected Macros

Download: [BU] Revert to Original File Name and Re-Enable Selected Macros.kmmacros (27.6 KB)


3 Likes

I have updated the REVERT macro, which stopped working when the Satimage.osax died.

Please use this AppleScript instead:

tell application "Keyboard Maestro"
   set macroList to every macro whose selected is true
   if (count of macroList) is 0 then
      display dialog "No Macros Selected" buttons {"Cancel", "OK"} default button "OK"
   end if
   repeat with aMacro in macroList
      set oldName to name of aMacro
      if oldName does not contain "__BACKUP" then
         display dialog "Non \"zz__BACKUP\" macros selected " buttons {"Cancel"} default button "Cancel"
      end if
      tell application "Keyboard Maestro Engine"
         set newName to search oldName for "zz__(.*)__BACKUP \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}" replace "$1" with regex
         set name of aMacro to newName
      end tell
      set enabled of aMacro to true
      
   end repeat
end tell
2 Likes