Revisiting Hazel

Hazel has been discussed a few times previously.

Apparently Hazel now has the ability to recognize OCR’ed text. I did not know this, and would like to reconsider using Hazel in conjunction with DTPO.

So, if anybody has any experience with this combination, a few questions:

If I ScanSnap items and OCR them into my DTPO inbox, can Hazel move items out of the Inbox?

Can Hazel recognize the Sorter, or otherwise move files into DTP so that they are appropriately imported?


Hazel watches folders in the file system. The global Inbox is associated with a folder. Hazel could watch that folder, but if DEVONthink is running when something is placed into the Inbox folder (e.g., by he scanner) then DEVONthink would probably snatch the file and import it before Hazel could do anything.

Hazel cannot watch groups inside your database.

Hazel can move things into the Inbox folder in ~/Application Support/DEVONthink Pro, and they will get imported from there.

Just curious, but what does this have to do with OCR? What are you looking to accomplish?

Thanks, Korm, can always count on you for a great response.

I was hoping that after scanning in a doc, or downloading a doc (such as a PG&E bill), that Hazel could recognize the doc, create the file name, and move it.

I can arrange to do this in Finder, but I have pretty much all my data in DTPO. And since my ScanSnap is set up to use DTPO and its built-in OCR, I am dependent on working within the DTPO database.

Sounds like it won’t work well.


But you could scan to some other folder that Hazel watches. It does its thing, then puts the file into the Inbox. Even more interesting, Hazel 3 also does AppleScript so Hazel could run a script that tells DEVONthink which database or group to put the file.

This is interesting. Thanks for pointing out the possibilities.

I would love to hear your thoughts or ideas on integrating Hazel.

At present, for example, I sign on to each website where I receive bills, download each as a .pdf, then use snippets in TextExpander to rename each .pdf, using the year and last month (which TE calculates automatically).

I then navigate to the appropriate group within DTPO, hit a keyboard shortcut that opens up a small global inbox (using a macro created in Keyboard Maestro), and drag the file from the small Global Inbox into the appropriate group I have opened.

I then close the Global Inbox small window, navigate to the next group, use the macro to re-open a small Global Inbox, drag, close, etc, etc.

This works pretty well, but is a bit tedious when I imagine Hazel doing it for me.

I just wanted to say that I’m really interested to this discussion. I’m new to Hazel but am really interested in the type of workflow that sawxray is describing. I’d be really interested for any tips, support, or advice on automating workflow - renaming files, importing, labelling and tagging, and moving.


I assume by “small global inbox” you mean some folder that isn’t the DEVONthink global inbox in ~/Application Support?

But, you could use the DEVONthink Global Inbox and, in DEVONthink, have two windows side by side – the first that’s focused on the Global Inbox, the second where you navigate around your databases. Drag from the Global Inbox windows to the destination. Or, even easier, have one window focused on the Global Inbox and use the Tools > Groups & Tags HUD to navigate groups and drag items from the Global Inbox into the target group.

Did you also know that the Groups & Tags HUD is persistent and always-on-top – meaning, it can be left open and anything from any filesystem browser (Finder, the Desktop, PathFinder, etc.) can be dragged into the HUD and therefore into that group in the database. Personally, I find that feature to be enormously helpful. (Unlike the Sorter, which has limited slots – though DEVONthink must be running and the target databases opened when you use this feature, and the Sorter doesn’t have that constraint.)

Its been a while, and I wanted to revisit, especially since the new version of Hazel can detect dates.

I wanted to find a way to download statements, for example, to a folder on my desktop, have Hazel search for the date and then create a file name using the creditor and date as per my standards, and then import appropriately into the specific folder in DTPO.

A couple of questions:

  1. Has anybody done something like this?
  2. If I allow Hazel to do its work, is there a way to import into DTPO? Should I just import to the global inbox, or to the folder in the database via the Groups & Tags HUD?

Thanks for any suggestions!

In the past I had some Hazel rules that just added the current date in yyyy-mm format to the filename, added tags, moved the file to an Indexed folder in DEVONthink, and then displayed a success notification. With the release of Hazel 3.1, it was an easy modification to change the Hazel rules to name the document with the actual invoice date.

Here is what it looks like (no, the document name doesn’t start with xxx-it starts with my account number which I have removed for this example).

For this example, my AT&T invoices contain a date range similar to 04/01/13 - 05/01/13, so I created my DateMatch variable as follows:

This allows Hazel to only pickup the ending date of the statement for naming the document.

David Sparks has a nice video on vimeo that shows how to create the DateMatch variable.

What David doesn’t show you is how to format the date for naming the document. That is done by editing the date pattern in the output.


Thanks, Greg!

A couple of questions for you:

  1. When you move to an internal folder, is it indexed by DTP?
  2. I know that video, and agree he doesn’t make it clear how to format the date for the file name. Your graphic was cut off just at the interesting portion. Do you just hit the disclosure triangle, and then format the date?

Also, from David’s video, there are dates with the last digit underlined or both digits underlined. Do you know what that means?


All of my databases are 100% indexed, so I don’t use any internal folders. All of the top level indexed groups have a synchronize script attached to them, so any time I select a group the index is updated, and external documents are indexed into the database and internal documents are exported out to the folder in the Finder.

If I used internal folders, I’d probably have Hazel move these documents to the Global Inbox or another folder that has a folder action script attached to import the documents into DEVONthink.

Yes, if you click on Edit Date Pattern, it looks like this:

If you click on Adjust Date, you get this:

That lets you choose the formatting of dates with single characters. If both digits underlined is selected, then the dates like March 8 will display as 03-08, while the single underline selected will give 3-8. If there is a chance that you will sort on these dates, you’ll want to select both digits underlined.

Thanks, Greg.

How would you handle it if you wanted to have Hazel move the newly renamed file into the appropriate group?

Would you have Hazel pop up the Groups & Tags window for you to manually select?

Or is there a way through a folder action to select the appropriate folder and import (since I import, not index, most of my documents).


Working with Hazel and contained groups is not something I have much experience with, but I did play around with this a little this morning. I believe that both korm and houthakker have considerable experience with this, and perhaps they will chime in with some thoughts. The Noodlesoft forum may be a good resource also-didn’t check there myself. I did find this link that appears to work well. I changed the script slightly to import into the default incoming group. It should not be much trouble to hard code the script to import into a specific database/group, and have multiple scripts for multiple destinations depending on the Hazel rule.

I changed:

-- Import the file.
tell application id "com.devon-technologies.thinkpro2"
  import _path name _name to create location "Inbox/Archive"
end tell


-- Import the file.
tell application id "com.devon-technologies.thinkpro2"
	import _path name _name to incoming group
end tell

I left the rest of the script, and the entire shell script, intact as described in the link. Let us know how it works out.