TRIGGERED NORMALLY
If the macro is triggered normally, a Prompt With List like the following will appear. By default, all Smart Groups are listed. The list can be limited using an optional macro setting.
TRIGGERED FROM ANOTHER MACRO
If the macro is triggered from another macro using the Execute a Macro action and one or more Smart Groups are specified (UUID or Name), the above Prompt With List is skipped and the backups immediately commence. As each backup completes, dialogs like the following appear.
BACKGROUND
If you are looking for a full-featured back-up tool, I suggest you check out:
There may be others that I've missed.
This macro was inspired by @ronald's idea in this thread.
DESCRIPTION
This macro provide a quick and simple method to back-up the macros listed in any Smart Group. All exported macros will be zipped into a single archive. The archive name includes:
- Date & time
KM Smart Group –
- Smart Group name
- macro count
zip
extension
For example,
2025-01-05 2249_04 KM Smart Group – 3-Cre Mod 2d (45 macros).zip
This macro uses the following Keyboard Maestro Editor native feature: File > Export Export as Folder.... As mentioned above, this macro then subsequently zips the newly created folder.
One nice feature of Export Export as Folder... is that it maintains the Macro Group hierarchy when the macros are exported. Thus, even though this macro keys off Smart Groups, the backup has a subfolder for the parent Macro Group of each macro backed up.
Since the macro is quick and simple, it's an ideal tool to use during macro development.
For example, you could create a Smart Group named Cre Mod 4h with two match strings cre:4h
and mod:4h
. Then run this macro and select that Smart Group. In just a few seconds you'd have a back-up of all macros created or modified within the last 4 hours, all saved within a single zip file.
Since the macro provides an option to reveal the archive after creation, it becomes very easy to manage the archive files.
SETTINGS
local_BackupRootPath
All backup zip files will be be written to this folder. If they do not exist, the sub folders in the path (below home: ~) will be created by the macro. The default is:
~/Documents/Automation/_Keyboard Maestro/Backups
If this path is not specified, the archive file will be written to:
~/Downloads
local_SmartGroupPatterns
This variable can be optionally used to limit the Smart Groups displayed for backup. Each line is used as a Regular Expression pattern.
If nothing is specified (the default), the macro will provide an option to back up any of the Smart Groups.
USING ANOTHER MACRO TO TRIGGER
This macro can be triggered using the Execute a Macro action in another macro and the Smart Group(s) are specified using the With Parameter, one Smart Group Name or UUID per line. In this mode, the interactive list of Smart Groups (via a Prompt With List) will not be displayed, thus local_SmartGroupPatterns does not apply.
In addition to the Execute a Macro action, the primary macro can be triggered using AppleScript within or outside Keyboard Maestro. Here's an example zipping two Smart Groups:
-- Zip Smart Group(s)
property theP : "1-Cre Mod 1h
F542D717-B0F7-4361-B44B-E16892686B67"
tell application "Keyboard Maestro Engine"
do script "43C753A4-C71C-45DD-9F65-346DB1A8350A" with parameter theP
end tell
Note that in this example a Smart Group name is used for the first Smart Group, and a UUID is used for the second. (See property theP
.)
TESTED WITH
• Keyboard Maestro 11.0.3
• Sequoia 15.3 (24D5034f)/MacBookPro18,2
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
( expand / collapse )
1.0 - initial version
2.0
a) Macro can now be called using the Execute a Macro action and the Smart Group(s) can be specified using the With Parameter, one Smart Group Name or UUID per line.
b) Macro name changed from Zip a Smart Group to Zip Smart Group(s).
3.0
a) Added feedback dialog if an empty Smart Group is selected.
b) Reduced pause durations. For those using a very slow mac, it might be necessary to increase them.
c) Improved efficiency and readability of the JXA code that gathers the Smart Group information.
d) Fixed a dialog typographical error.
PRIMARY MACRO
Download: Zip Smart Group(s).kmmacros (75 KB)
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 15.3 (24D5034f) PRE-RELEASE SEED SOFTWARE
- Keyboard Maestro v11.0.3