Using a single smart rule instead of Hazel (maybe)

For other people coming across this I found this documentation for JXA. Seems to be a pretty good source for info. There’s lots of people out there complaining about how Apple hasn’t kept up their documentation so this should help.

<marketing blurb>
There’s a more thorough and recent JXA site out there, too
</marketing blurb>

1 Like

You can also replace Hazel with the Folder Actions Service built in macOS to run scripts upon certain events.

1 Like

@chrillek

const groupFound = app.search(`name: ${group} kind:group kind:!tag`, {in: app.databases[db]});

I’m using the same group name multiple times (e.g. I have the subgroup Documents in each project group).

Is there a way to restrict the search for a group when using the same group name multiple times? Can I include the parent group in the search?

I found a solution. I instead of using app.search() for finding a group I can use app.getRecordAt():

  const group = "/Dokumente";
  const db = app.getCustomMetaData({for: "Datenbank", from: record});
  if (!db) {
  	return;
  }
  const groupRecord = app.getRecordAt(`${group}`, {in: app.databases[db]}); 

You could also use createLocation, I think. But I’m away from my Mac, so can’t check.