What is Best Method to Restore Macro from Macros Sync or Plist File?

Today I needed to restore a previous version of a macro. It is easy enough to obtain the giant file that contains ALL macros, from either the sync file or macro plist file.

This is either:

  • <path to sync folder>/Keyboard Maestro Macros.kmsync
    • BTW, @peternlewis, I don’t see a way to get this path. Did I miss it?
  • ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Macros.plist

IAC, you can obtain an earlier version of either file from either Time Machine or other backup system. In my case, I used my DropBox Versions feature.

Fine. But once you have this file, how do you get the macro of interest out of it?

  • I don’t see any KM provided tools to help with this.
  • I looked at the very long XML file, but it was not obvious to me how to extract the XML just for the macro.

So, here is my workaround, but I’m looking for a better, more automated solution:

  1. Restore the earlier KM sync file to another file name, but put it in the KM sync folder.
  • I used “Keyboard Maestro Macros RESTORED <date>.kmsync”
  1. Stop the KM Engine and KM Editor app
  2. Rename the current sync file to add “OLD”
  3. Rename the restored sync file to what KM expects:
    “Keyboard Maestro Macros.kmsync”
  4. Launch KM Editor, which auto-launches KM Engine.
  5. Find the macro of interest, and export to file.
  6. Stop the KM Engine and KM Editor app
  7. Rename the current sync file to something "RESTORED <date>"
  8. Rename the original (current) sync file back to what KM expects:
    “Keyboard Maestro Macros.kmsync”
  9. Launch KM Editor, which auto-launches KM Engine.
  10. Import the old macro file
  11. Now I can use it as I need to (kinda :wink:)

Surely there is a better way.

@peternlewis: Feature Request:

Provide a KM tool/menu item that would search a macro plist or sync file, allow the user to select found macro(s), and then import the selected macro(s) into the current set of macros, maybe into a “Restored” Group.

TIA.

P.S. @peternlewis, this was requested in another topic, but here is a great example / use case of why we need to have multiple windows for the actions in a Macro. I needed to compare my current macro with the prior version to identify changes I needed to make.

A macro is like a document to many other apps. And all of the apps I know of that use documents support displaying multiple documents in multiple windows.

Please consider adding this as a feature.

Addressing your immediate issue of getting a macro restored and ignoring the broader issues you brought up which are for @peternlewis to address, my method is like yours but I think simpler. Let’s say Today you want to restore a macro from Yesterday.

In the KM Editor, I’d use File > Revert Macros > Yesterday to restore where I was Yesterday. I’d export the macro in question, use File > Revert Macros > Today to get back to where I was earlier Today, then go to the Finder to double-click on the exported macro to get back the macro in question. Of course, you’d then need to do any cleanup of the copies of that macro since you’d have Today and Yesterday copies.

3 Likes

Thanks for sharing. That is a much simpler process.

I did see the "Revert Macros" menu item before, but there was no indication that I would be able to restore back to the latest version, prior to a revert:

Even the KM Wiki does not provide this info:
Revert Macros

The Revert Macros command in the File menu lets you revert to a previous version of your macros. If you find you have really messed up your macros, you can revert to how they were when you first launched Keyboard Maestro, or how they were yesterday or even several days ago.

So, to be clear, AFTER I do a revert to prior date, the menu will show "Revert Macros > Today"?

And, by today, does it mean the version just prior to the last revert?
@peternlewis, can you please confirm?

That’s an understandable concern I hadn’t considered or ever faced, whether your second time reverting would bring you to where you were earlier Today. That makes me wonder if it would be both worthwhile and feasible for there to be something like a File > Backup Macro File Now option for situations like this when the user would like an opportunity to save the macros where they are at a specific moment. (That’s not to say that should be done instead of the feature request in your original post as each idea is a distinct functionality.)

1 Like

File ➤ Reveal Macro Sync File.

Firstly, before doing this, I would generally quit and relaunch the Keyboard Maestro editor, because one of the revert options is always Revert to at Editor Launch.

After reverting, a new option is added for “Revert to Before Last Revert”. So it is safe to Revert, export, and then Revert to Before Last Revert.

However, as said, for added safety, relaunch the Keyboard Maestro editor first, otherwise if you accidentally choose the wrong entry when you go to select “Revert to Before Last Revert” you could lose your original macros, leaving you forced to choose between At Editor Launch and yesterday’s, whichever is later.

2 Likes

Thanks to the above help I received, I have finally determined a good, easy method to restore a macro from a prior version. See:
###Tutorial – Restore Macro from Prior Version - YouTube

1 Like