MACRO: Macro moving and renaming aid

When I post macros here in answer to someone's question, I keep a copy in Keyboard Maestro. But I almost never use these myself; they're around mainly for reference in case I want to remember how I did something.

To make it easier to keep track of these macros, I put them in their own group, and change the name to start with the date I created the macro, in YYYY-MM-DD format, like this:

I was growing tired of manually renaming these macros, so I wrote a macro to ease the task—it works on however many macros (it should also work on groups, though I didn't test it) you currently have selected. Here's how it looks in action:

Caution: Animated GIF within

rename_aid

If I press the Control key while the box is onscreen, I can enter a custom date; otherwise, today's date is used. The macro then renames the files, adding the date and divider bar to the start of each filename. Here's the macro:

Download Macro(s): Insert date at front of macro-group name.kmmacros (40 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4.1
  • Keyboard Maestro v11.0.2

The last step in the macro is an AppleScript, which contains a section (well, two identical sections) of disabled commands:

--tell macro id uuid to set enabled to not enabled
--duplicate macro id uuid to macro group "Name of other group"
--delete macro id uuid

The first one disables each renamed macro, and the next two move it to another group and then delete the original. If you want to use these, uncomment them in both places in the macro (yes, I could have written a subroutine for this; I'm lazy and a horrid AppleScript coder), and change the name of the group to the actual group you want to move the macros into.

This is also more of a template macro for doing any sort of macro renaming task you might need to do—it could be easily modified to add things at the end, insert more dynamic information into the name, etc. For my needs, though, I love how it works—after I post a macro, I select it, hit the hot key, and it gets renamed and filed.

EDIT: The AppleScript at the end is 90% others' work. A few bits I found here on the forums, and then ChatGPT helped me with the looping syntax, which I never ever remember for AppleScript :).

-rob.

4 Likes

I have modified the above macro in some important ways, but it's also different than the above macro in that it does more (and a bit less). This new version will not work with macro groups, just macros. But it is now a toggle—it will either archive (rename, deactivate, and move to a defined storage group) or restore (bring back the old name, reactivate, and move to a defined active group) any number of selected macros.

Download Macro(s): Archive or restore macro(s).kmmacros (51 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.4.1
  • Keyboard Maestro v11.0.2

With a macro selected (or multiple, but I'll refer to a single macro), the macro will insert today's date (optionally a customized date if you press Control after it launches) and a user-defined separator at the start of the macro's name, deactivate the macro, and move it to your defined storage folder.

If you select a macro whose name matches the pattern of "date plus separator" at the beginning, then the macro will reverse everything: It removes the date and separator from the name, reactives the macro, and moves it into a defined active group. As a last step, it then selects that group.

I found I was moving macros back and forth a fair bit as I worked on them after I thought I was done with them, and this macro makes it simple, as it's the same activation keys.

To use, edit the green box at the top to reflect your own usage: Specify how long the macro waits for you to press Control to choose a custom date, set the Group name for both the archive group and the group to restore into, and set the separator text that will go between the date and the original filename. Unlike the first macro, you do not need to edit any AppleScript to use this.

-rob.

1 Like