Yes, it’s another of my “musings…”
I consider Alfred, Hazel, and Keyboard Maestro to be “must installs” on every one of my Macs. In fact, Alfred is the third app I install (for those who are curious, the first two are 1Password and Dropbox, in that order. 1Password is needed for activation keys and passwords for everything else, and Dropbox is needed for data syncing for Alfred, KM, etc and so goes second); I am so used to typing ⌥-Space that I pretty much cannot use anyone else’s Mac or launch an app without it.
There is much overlap between these various utilities, and I am always debating whether to create an Alfred workflow or a KM macro. This post is not about that.
Hazel has long been my go-to app for file automation, using its rich set of tests and actions, often supplemented by my own scripts in bash, AppleScript or python. I have not, to date, used KM for automation despite its ability to trigger “monitor a folder for changes.” I prefer as much as possible to keep a given task with one app to avoid redundancy, confusion, and conflicts.
In the aftermath of David’s KM Field Guide, I’ve been playing a lot with KM, and realized that there is a use for KM’s ability to handle files in another way, however. I have been working on a macro for a specific purpose. I have a “.logs” folder where many of my homegrown scripts write log files with their operations for documentation and/or debugging. Hazel monitors that folder and renames log files each day to a file with the date appended, so there is a new log file every day, and after 10 days deletes a file so they don’t accumulate beyond bounds.
This means Hazel has to scan that folder each time it runs, which is not all that much system overhead, but it occurred to me that I really "should’ have this run more like a cron job, once daily at 12:01 AM to rotate log files, since there is really no need to check the folder any other time.
So I am putting together a KM macro to take over this function.
As a result, my “musings” have lead me to think:
- Hazel is the app of choice when real-time operations need to be carried out, so that continuous monitoring is desired;
- Hazel is the app of choice when tests and actions apply to a given folder or files in a folder;
- Hazel is the app of choice when its rich set of tests and actions apply to the task at hand.
BUT:
- KM is the app of choice when actions on files need to be run based on a specific trigger such as a particular time of day or a system event, but not on a continuous or real-time basis;
- KM is the app of choice when actions need to run based on a non-folder local trigger and run on files spread out amongst multiple folders, or on a selection of files in the Finder;
- KM is the app of choice when the actions should be run based on user triggering (eg trigger the macro via a command-key sequence, typed keyword, selection from menu or palette) rather than on a background basis;
- KM is the app of choice when a folder needs to be monitored but the actions required are NOT covered by Hazel or KM but are best handled via a complex scripting solution.
And so that’s how I am dividing my use of Hazel and KM, at least for now.
Thoughts?