KM's Folder trigger doesn't work on some folders. Can I fix this?

I found where my mail is stored, it's in subfolders of ~/Library/Mail/V6

So I created a trigger that monitors one of the subfolders. When files are added to that folder, KM is supposed to trigger the macro that the trigger is attached to. But it doesn't trigger. Are there some folders that KM cannot trigger on, perhaps due to system privileges? Is there some way to fix this? Perhaps with sudo or something?

I really, really want to have a trigger that activates when new mail arrives. If someone can tell me why KM doesn't trigger for my mail folder, I'd appreciate it.

I would prefer to have a trigger that activates when an SMS message arrives. I also found the folder where SMS messages are stored. But KM also refuses to trigger on changes to that folder. but to make SMS worse, the data files are about 50% binary unreadable garbage. At least the mail files are readable.

Bonus question: can KM trigger on file changes or only on file additions/deletions? I can't make it work for file changes, even though there is a switch that says "ignore changes". Since KM is probably polling the folders, why can't the action poll for file timestamp changes?

This really sounds like a job for launchd rather than Keyboard Maestro. You can have launchd watch a file or folder for changes, and then when that happens, you can call an external program (including a script that would trigger a Keyboard Maestro macro, I presume).

Here's one that I use to monitor changes to the file ~/Library/Application Support/Spectacle/Shortcuts.json and then run /usr/local/scripts/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
		<string>~/Library/Application Support/Spectacle/Shortcuts.json</string>

You should be able to adapt that, I'd think. If not, please let me know and I'll do what I can to help.

I know a lot about crontab, but I've never heard of launchd. I've tried googling it. It sounds like some sort of macOS utility/service. I can look into it, but do you have a recommended way I can learn about it?

Ok I've found one site on the web that tries to explain this service. But I'm not sure why you are saying I shouldn't use KM to do this. This should be perfectly within the capability of KM to detect.

There is a very nice GUI for launchd, called LaunchControl. It greatly helps you to write or edit launchd configs, and also helps you to understand the various mechanics.

LaunchControl GUI example:

1 Like

launchd is the Mac version of crontab which is much more powerful and flexible. In fact I would say that it's a replacement of crontab (although you can use crontab syntax with LaunchControl) plus a whole lot more. is a good site to learn from. It is run by the folks who make LaunchControl. I use and :heart: LaunchControl big time.

Well, you're right… I think Keyboard Maestro can do this… but it's just the type of thing that launchd is especially good at. I use Keyboard Maestro, TextExpander, Hazel, and launchd even though I could probably do 99% of all of them in Keyboard Maestro.

But, since you're asking for help on the Keyboard Maestro forum, it's perfectly reasonable to expect a Keyboard Maestro solution.

Thanks for your support. My question was why doesn't the KM trigger for changes in folders work in certain folders. If anyone can answer that I'd appreciate it.

I also had the problem with a folder monitored by KM on MacBook Pro @Sleepy. Everything was set correctly, until Thursday the macro worked fine too. On my iMac I have no problems with the same macro.

The solution for me was to delete the macro and recreate it again... now it runs again without problems.

Can you please specify which folder you are tracking?

Unless I missed something, you only said:

I found where my mail is stored, it's in subfolders of ~/Library/Mail/V6

So I created a trigger that monitors one of the subfolders.

But even the subfolders of “V6” contain more subfolders (.mbox), and – as far as I know – KM’s folder watch does not watch the contents of subfolders. (Correct me please if I’m wrong.)

If I told you which folder it wouldn't help you because you wouldn't have that folder. These folders are created dynamically by Mail and Messages. All I can tell you that will help you is that it's a subfolder of the path I gave you. You can pick one in your own folder structure if you need to, I can't tell you what your folders will be called. Find one with mbox files and try it there.

I don't need KM's folder watch to watch subfolders. That's not what I want. I just want it to watch a single folder, which corresponds to a single mailbox. And it can't even do that. Why can't KM monitor any folder in this structure? Is it a file permission? How do I fix that?

I verified that KM’s folder watch does not track the contents of subfolders.

So, this is your problem, and I think, it makes it impossible to watch folder structures like the one of Mail. As you said the subfolders of, for example, INBOX.mbox of your iCloud account are created dynamically. So, I don’t see a way to do this with KM’s folder watch.

I have no clue if launchd’s WatchPaths is watching the contents of subfolders, test it with @tjluoma’s config. (You have to adapt it.)

Another option would be to attach a Folder Action Script to a folder. I still have to check out if it watches subfolders. I doubt it, but maybe.

To make it clear: The folder that “corresponds to a single mailbox” does have many subfolders:


Even if you go down to the INBOX, there are still many subfolders.

Yes. You are correct. Are you saying that's a problem? I'm sure KM should be able to handle a couple of subfolders with short names. But it can't monitor these folders. If it could, I would be able to do some fancy stuff, like monitor incoming emails by a trigger and then hopefully read them and react to them in ways that Mail Rules can't.

Well, I don’t understand the “short name” thingy, and what is a couple (where is the limit? 2, 3, 4, 10 subfolders?), but I think you should make a feature suggestion out of this, directed at @peternlewis.

My guess is he hasn’t implemented it because it can become very expensive.

When I say "short name" I'm referring to the folders with the names of "1" and "2". Those are pretty short names. I'm sure KM can handle folder names with only one character. I don't need to make this into a feature request.

All I'm asking is why the folder trigger refuses to work on these folders. Have you tested it yourself? Do you concur that the problem exists?

Oh I see why you are confused. You continue to think that I'm asking for subfolders to be tracked. I stated at least twice I don't want that. I will repeat it again... I don't want the KM folder trigger action to track subfolders. I just want a single folder to be tracked. But it isn't working. KM fails to monitor a single file in this folder structure.

As said, I have verified that it doesn’t work on subfolders.

The length of the folder name is not the problem, why should it be?

Hence, my recommendation, make a feature suggestion. (“Watched Folders should have an option to include subfolders.”)

Ok. Fourth time. I don't want the feature you are asking me to request.

I just want KM to be able to monitor a single folder in my Mail folder for changes. It can't do that.

Nope. KM works perfectly fine watching a folder for added files.

That’s why I asked you to tell me what exact folder you are watching. (It doesn’t matter if this folder exists on my disk.)

And my impression was, you were watching a mail-account folder (or an Inbox folder of a mail account), and these folders do have subfolders – at least here – and KM simply does not watch subfolders. That’s all :wink:

Why don’t you simply post a Finder screenshot of the folder you are watching?

Sure, no problem. But I will quadruple check first. I've already tried at least three times, but I'll try again and find a way to post the results here.