How Do I Monitor a Folder for New and Updated Files?

I am trying to create a macro to monitor a folder and open any new markdown file or old markdown file whose contents have changed.

Using old posts and some youtube videos, I have been able to create a macro to watch a folder for a particular type of file.
I have a folder of markdown files which I create using a particular app, Highlights.
Is it possible to have the macro open any new or updated files in the folder?

1 Like

I wouldn’t use keyboard maestro. Take a look at hazel. It’s excellent and you can run your kb maestro scripts through it. http://www.noodlesoft.com/hazel.php

2 Likes

Have you considered using AppleScript Folder Action Script?
They are designed for just this purpose.

Thanks. Just what I needed.

Should get Hazel very soon! I have heard a lot of good things about it!

Yepp, KM and Hazel are a perfect combination. I use them together a lot.

1 Like

Hazel is an awesome program that does a stack of things really well.

However do note that version 7 adds a Folder Changed trigger that can tell you when a file is added or removed from a folder, so for simple cases Keyboard Maestro may be able to sort you out.

Hazel has way more power in this area though, and similarly to TextExpander, if you have heavy needs they are definitely great companions to Keyboard Maestro.

2 Likes

Thanks. I have been waiting for this . I want to create a simple macro to alert me when new files are added to my download folder and open the folder, highlighting the new files. How do I go about it?

Reveals the user's ~/Downloads folder in the Finder.

Reveal Downloaded Files.kmmacros (1.7 KB)

I realize this is an old thread, but just in case anyone new finds their way here like I did:

In the Reveal Downloaded Files macro posted by Peter above, the Reveal field is populated with:

~/Downloads/%TriggerValue%

I'm finding that it only needs to be:

%TriggerValue%

... which returns the entire path (e.g. /Users/name/Downloads/filename.extension).

Perhaps the Reveal File action has changed behavior during the last 4 years. :slight_smile:

It is not the Reveal files that has changed, it is the token %TriggerValue%, which used to return only the file name. Now, as you have learned, it returns the full POSIX path.

2 Likes

Is there a way to monitor subfolders as well within the parent folder? This script only monitors the parent folder.

Hey @Giel,

Not with Keyboard Maestro I'm afraid.

-Chris

Hey, everyone. I found this thread while trying to build the exact macro Peter shared above to reveal my screenshots folder after a new screenshot is added.

I built the macro, and it works, but I think I've run into a bug because it only works once, and then stops working and crashes KM. I'm not sure if it's because my folder is Dropbox (I saw another thread mentioning that was a potential issue with the Folder trigger).

What happens, more specifically, is that after the first successful run, nothing appears to happen when it should be triggering again. When I open KM after it has failed a few times, I get a message that KM has crashed and can submit a report. It happens consistently and repeatedly.

Here's the Macro I'm using:

Any thoughts?

Hey there, that is very odd to me, as I have a similar macro that works without fail every time, albeit not in a Dropbox folder. There’s nothing wrong with the macro that I can see; I mean it’s about as basic as a macro can be so there’s not much that can go wrong with it haha. Hopefully (likely), somebody far wise than me will chime in soon with more insight.

You might also consider either reaching out through the help menu in KM itself (since it is crashing) and/or starting a new thread as this is deviating slightly from the original topic.

Hey Dan,

Dropbox plays all kinds of games behind the scenes between synchronization and versioned backups.

Crashing Keyboard Maestro though needs to be reported to @peternlewis – Peter?

-Chris

Send the crash report to support@stairways.com

It would be in the ~/Library/Logs/DiagnosticReports folder

You can get to ~/Library (which is in your Home folder, but generally hidden from you) in the Finder by holding down the shift (or option) key and selecting Library from the Go menu in the Finder.

Keyboard Maestro will generally send the crash reports to me if you've allowed it, and if you have included your email address then I can chase it up with you, but having the actual cause is often very helpful.

Keyboard Maestro gets very few crash reports.