Page 1 of 1

Automatically create hazel rules using applescript

PostPosted: Mon Mar 13, 2017 11:34 pm
by willtmc
I run an auction company. We create new auctions all the time. Our auctions require a lot of documents. Usually, the documents contain several identifiers that I hope can be used to automatically sort them into the right place.

Each auction has a code, i.e. 130-smith or something like that.

I could create a table that looks kind of like this and the table would contain all the information I know I would need to sort the document into the right folder:

Code: Select all
+--------------+----------------------------------------------------------------------+
| AUCTION CODE | IDENTIFIERS                                                          |
+--------------+----------------------------------------------------------------------+
| 130-smith    | John Smith, Jane Smith, 130, 130-smith, Smith Estate, 123 Smith Road |
+--------------+----------------------------------------------------------------------+
| 131-jones    | Jim Jones, 131, 131-jones                                            |
+--------------+----------------------------------------------------------------------+


I can create a new Hazel rule using this information, but I don't want to have to do that every time we create a new auction.

How can I create a workflow that will automatically create a new Hazel rule each time we create a new auction?

We use Podio to manage our auctions and I can pull the information from there to just about anywhere with Zapier.

I don't know how to get it from Zapier to Hazel, however.

I think it will require copying the data from Podio to my mac and creating a table of some sort. Then, I assume I'll need to use Applescript to reference the data table and pass the information to Hazel. I need help. Thanks in advance.

Re: Automatically create hazel rules using applescript

PostPosted: Tue Mar 14, 2017 11:43 am
by Mr_Noodle
I don't anything about Zapier but if you are writing an AppleScript, have the script check the data file and keep it to one rule. No need to make an unmanageable mess by creating hardcoded rules for each case.

You can have Hazel run an AppleScript that will check the table and export custom attributes back which can then be used in patterns in actions, like the Sort into subfolder or Rename actions. Search for AppleScript in Hazel's help for more info on how to do that.