Import from Hazel to various groups - JavaScript

First off, it’s never a good idea to hijack an old thread. This one dates from 2020! Things have advanced since them.

The basic idea was (was!) to have Hazel forward information to the script. The script uses this information to select the correct database and group to send the files to. In the original post, the information was 1234 and tag1, and the groups were group1 in database1 for 1234 and group2 in database2. The script (which was written to be run in Hazel!) provides the information in its inputAttributes array.

After all that, I proposed another script here

That one is run in DEVONthink, at it’s more or less what I still use today for many PDFs. No need for Hazel anymore. The basic approach is

  • check the PDF for OCR and apply OCR if necessary
  • check the text in the PDF for certain patterns (key)
  • These keys are associated with functions (handlers), databases, groups and possibly tags lists
  • The handlers can do whatever they want to the file (rename, set custom meta data value)
  • Tags on the file are set depending on the content of the tags list
  • The database/group are used to determine the location the file is moved to after processing

It all boils down to a single script to handle all regularly arriving PDFs (account statements, invoices, whatever merits automation). But the code needs customization and a lot of experimentation. And it’s certainly not meant for ChatGPT to “improve” on it.

1 Like