Can KBM monitor attributes of files in certain locations like Hazel?

  • Can KBM macros be created that monitor files in specific folders?
  • Can KBM create rules that act on those files if they match specific criteria?
  • For matching purposes, can KBM evaluate the contents of the metadata in the Comments area of the Finder's Get Info?
  • For example, if the Comments attached to a specific file contained, "Review after [date]", could a macro act on that file if the date was > = today's date? In this example, "act on" would mean moving the file to a different folder or possibly delete it.

I'm considering this as one way to automate the process of de-cluttering my hard drive by creating an "Expiration Date" in the Comments area when I create / scan a document with a defined term. e.g Insurance Policies, Non-Disclosure and Non-Compete Agreements, Leases, Warranties, and other documents with a defined period of relevance.

Thank You.

Yes. Though for this you'll probably want to create a macro that runs periodically. The "Periodic" trigger will probably be too frequent, so consider either the "At time" or "Cron" triggers, depending on the complexity you want. Links to all those on the Triggers page.

Yes and yes -- you can use the Get File Attribute action to get any comment text and process that in the usual way. So you could use a regex to extract the date, compare that to "today", and act accordingly.

If you do go this route, standardise your date format. I suggest using yyyy-MM-dd -- the advantage being that you can leave it as text and still use ASCII sort order to determine "is before" and "is after" (much easier than doing date conversions!). You can get today's date in that format in KM using the token %ICUDateTime%yyyy-MM-dd%. As an example:

Date as Text Comparison.kmmacros (2.6 KB)

Image

Finder comments, however, aren't 100% reliable -- see this blog post. You may not have a problem, depending on how you are setting the "Comments" date, but err on the side of caution until you're sure, for example by moving rather than deleting files.

Depending on how many files you are planning to scan, there may be better ways of doing this -- getting the Comments of lots of files could be quite disk (SSD these days, I guess?) intensive. If I was sure my dates were going into the "Get Info" box's "Comments" field (again, see the blog post for why) I'd look at using Spotlight instead because it's a lot quicker to search a database of metadata than it is to query each and every file in turn (most of which will be a "Nope, not yet"). That may require a change to how you format the dates in the "Comment" box though...

2 Likes