Is it possible to trigger a Hazel rule with a KBM macro?

I have a number of Hazel rules that I run manually, from time to time, when the need arises (as opposed to monitoring folders). I am looking for a way to quickly trigger a Hazel rule without having to call up the Hazel SP panel, click on the rule , activate it.
thanks very much for your time and help

How about having a KBM macro create a file that Hazel watches for. It needn’t have any content.


a very smart idea !!. Life is unfair: why are some people so smart !

  • would you be so kind as to give me some indication as to how would I write a macro to a dummy file, for example ‘Hazel cleanup trigger’ (txt?) in my downloads folder?
  • obviously I only want to trigger the macro once, and would have to delete the file afterwards. What would you suggest. I am not sure if I would have to take into account the Hazel folder monitoring cycle frequency.

This is all easy enough once you know about KM's file actions:

Trigger Hazel Rule.kmmacros (1.8 KB)

You may not have to pause for this long to wait until Hazel is done, but I figured it was better to start with a generous time allotment and decrease it as testing proves viable.


Your macro works fine, ie create and delete file.

Thank you very much !!

I am lost as to how to configure Hazel if it is not too much to ask.

The objective is that if the Hazel cleanup trigger.txt is present in the Downloads folder, then everything (files and subfolders) in the Downloads folder is moved (with replace if necessary) to the Downloads DUMP TEMP folder.

Here is my feeble attempt.

if I may also ask you: how would I configure in KBM (nothing to do with Hazel) a macro to

  • move all files from folder X to folder Y
  • including (also move) subfolders
  • replace without asking

Although I have and use Hazel a bit I'm not that familiar with it, so I'm at just as much of a loss as you on whether there's a way to have a trigger file move all of the files and sub-folders in its folder to another folder. Fortunately, I do know how to accomplish that with KM, and it's not too difficult. The only aspect I found to be less than intuitive was replacing without asking, which the Move or Rename File action doesn't have an option for by default, but once you realize that replacing an old file with a new one is essentially just deleting an existing file with that same name before moving the new one, the logic of how to handle that in KM becomes clear:

Move Everything in Downloads.kmmacros (3.4 KB)

Just replace ~/Desktop/ here with the path to the folder you want to use and I believe this should do the trick.

1 Like

Have you tried using UI Scripting with AppleScript to use the Hazel menu?

I don't have Hazel, so I don' t know if this is doable, or feasible. It is just an idea.

For anyone interested or curious about Hazel, I found this YouTube to be very good:
Getting started with Hazel

1 Like

Hello @ronald, I can offer you this one...

Hazel Rule Pause:Run.kmmacros (1,9 KB)

1 Like

Thank you very much for your answer, the script and the video !
Very kind of you !

It works perfectly. Thank you so much !

1 Like

Thank you for your reply.
You are right: it is possible to implement scripts with Hazel.
The problem is that I don’t know how to write scripts.
Thanks for the VERY INTERESTING video.

One other option, rather than creating a file, is to apply a tag to it. (I don’t know how to do that in KBM.)

I do know you can check for tags and add or remove them in Hazel.

I used this technique once to handle a printer ownership problem:

  1. Put the file to be printed in a special folder in Dropbox.

  2. Have Hazel check for files in that folder without the “Printed” tag on them.

  3. Have Hazel print such files and then tag them.

A different use case but might be interesting here.

1 Like

a very interesting suggestion. thank you very much.
It allows me to solve the problem of cycling through all files one by one.
If you had a minute, I would greatly appreciate your opinion regarding printing: system vs using an app.
I am concerned that Hazel will use the system printing and force me to use color, which would be out of the question.

apply a tag to it:


thank you.
I assume that you mean: open file ➜ print➜ close➜ tag file as printed ➜ next file until all files are tagged.
How do you manage the until all files are tagged part?


  • a Hazel rule (on the Downloads folder), which moves any file if and when it acquires a 'move' tag,
  • it will be enough to use a KM action which adds a tag.

Here is an add tag action, nested in a For Each, so that it tags all the files in in Downloads folder as due for a move, but you could be as targeted or as broad-brush as you want.

Of course, you don't really need Hazel for this – KM could move the files for you, as well – but here is a Hazel rule which moves the file (and also clears the triggering tag).

1 Like

thanks very much for your time and macros/rules.
It is very much appreciated.

I am now confused: you are pausing Hazel, not a specific rule in Hazel ?
I have difficulty understanding the video now.
herzlichen Dank

@MartinPacker @appleianer

A very good idea Martin. I tried it but got stuck writing the Hazel rule.

The KBM macro works fine, and I want to create a KBM Hazel palette each one creating a file which triggers a specific rule in a specific folder.

My problem is writing the Hazel rule. Hazel finds the created file (so the conditions clause is fine), but only 'acts on' (here sends to trash) that specific file. Would you have any idea how to configure the Do the following clause so that ALL files are sent to trash if the trigger file is found?

thanks very much for your time and help

The following Hazel rule only sends the trigger file to the trash, instead of sending all files in the downloads folder to the trash