Making DT3 and hazel play nicely? (DT to Hazel)

Just wondering if anyone figured out a nice way to make DT3 and Hazel play nicely. Specifically I want to use the Hazel automation rules to process documents from DEVONthink, after DEVONthink OCRed and processed them. Mainly content extraction, title normalizations, etc. I know I could probably do it with applescript, but I already own Hazel and Hazel is nice.

All I can think of is using smart rules with applescript to copy a variant of the document into a custom folder, then re-import it. There is a “Move to external folder” action, but I can’t figure out how that one works

Any ideas?

2 Likes

Move to External Folder moves a created or imported DEVONthink item to an indexed Finder folder its located in. This is called deconsolidation and actually happens by default when you put items in an indexed group in a database.

After DEVONthink "OCRed and processed them" in what way?

On document import I automatically OCR through DT3 if the target document is a PDF, then try to do some very simple content matching for keywords and automatically rename if possible. (Eg, “2022-03 Water Bill”)

Afterwards I want to do some more advanced matching on the content to extract things like dates or normalize titles (simple things like turning 2022-3-2 into 2022-03-02 among others). DT’s “Scan Name” / “Scan Content” work ok-ish, but Hazel is still more advanced, especially when try-and-error-ing rules

Can you think of a good way to hand-off files to a Finder folder? When you say “put items in an indexed group in a database”, do you mean the feature of just indexing stuff on the filesystem without importing those into DT? So, moving a file from DEVONthink into a indexed folder (within DEVONthink) will move it to the filesystem?

Hazel’s USP is that it watches over folders and handles files arriving in these folders. So you’ll have to export your files from DT to a folder somewhere in your filesystem that Hazel watches over.

There’s the export menu in “Files” to do that. It does not seem to be available directly in smart rules, but you can script that.

So while in theory it is feasible, I doubt that it’s a smooth process. Because after you’ve processed your files in Hazel, you’ll have to reimport them into DT, preferably into the correct database/group. And on top of that (or rather before that), you’ll have to provide Hazel rules for all your documents. Which is easier to do than in DT, but it’s still a fair amount of work.

I once tried to do something like that (in fact, I even OCR’d stuff from Hazel using PDFPen): Process everything in Hazel and then add it to DT. Since that involved a fair amount of scripting (for the “move to the correct database/group” part) anyway, I dropped the idea in favour of a smart rule basically running a (longish) script that does everything™: OCR if necessary, extract the date (depending on the kind of document) and use it to rename the document, add tags if needed and save the amount (for invoices) in a custom meta data field.

The script is here

It’s provided as is with no warranty. You’ll have to adjust the data at it’s beginning to reflect your documents and database structure. Some of that is discussed in the thread.

Can you think of a good way to hand-off files to a Finder folder?

The easiest way is by using an indexed group.;

When you say “put items in an indexed group in a database”, do you mean the feature of just indexing stuff on the filesystem without importing those into DT?

Yes, that is correct.
And while I generally do not advocate using indexing without careful consideration, in this specific case it’s just being used as an automation mechanism.

So, moving a file from DEVONthink into a indexed folder (within DEVONthink) will move it to the filesystem?

Yes, moving a file from DEVONthink into a indexed group will move in into the indexed Finder folder.

But then one would have to either

  • limit oneself to one group in DT storing all those files that Hazel processes, or
  • have to set up several groups and move the files to be processed by Hazel into the appropriate ones, or
  • re-import all the files after Hazel has processed them into the approprate DT groups.

I’m not saying that it is not feasible. I’m just not convinced that it is particularly practical or easy to handle.

2 Likes

That’s what I was thinking. So files that need processing → use Smart Rules to move them into a indexed group. Hazel then kicks in on those files, processes them and then just re-imports into DT, either through AppleScript or by using the Inbox folder

I don’t need to import those files into specific groups because I do the processing only on first import. So everything is going from/to Inbox before I move those into the correct place

I’ll give this a try and see how it goes

Hi there, I was thinking the exact same question concerning usage of Hazel and DT3. How has the process been for you so far? I hope it is smooth. (p.s. I am a tech idiot and I know nothing about automation) It looks too complex I might inadvertently mess up my system.

No offense to Hazel and its developer but there are many of its functions DEVONthink can do with its own smart rules. So I guess it depends on what you’re specifically trying to do. There is no general “you have to use Hazel for that” with smart rules.

2 Likes

I see. Thank you for replying - I guess I haven’t read the potions concerning smart rules - as a side note - is 1TB sufficient for a laptop as a data base source ? Also, just wondering which smart rule should I try starting to get a hang of automation?

If you have less than 1TB data: yes. Otherwise not.

Sorry, but your question makes no sense at all without you providing any context. If you want to store your personal invoices in DT, 1TB should be largely sufficient. If you intend to save 100 years of Hollywood movies in HD, even 10TB would not suffice.

Thank you for pointing that out. I am assuming that this includes all the zoom videos that I have lectured as well as legal documents and movies that I bought. Having said that, since I am within the confines of an time machine, external hard disk (I have a 2 TB) I assume that my best bet would be limiting myself to 2TB? Out of curiosity, do people operate their devonthink 3 product with an external hard disk? Assuming if I migrated my MacBook Pro to a new one, would it be just simply uploading the database into the new MacBook Pro?

I suggest that you open a new thread to discuss hardware requirements.

and movies that I bought

Bear in mind, DEVONthink is not a Finder or Spotlight replacement. While DEVONthink can hold many file types, be judicious in what you put into your databases. Here’s an old but still relevant blog post…

1 Like

Will do. Thank you.

Thank you for this. I got a silly question, does Devonthink have any project mapping capabilities such as having a timeline on date where I started working on a pdf and I can journal my progress?

Not silly at all but no, there is no built-in timeline function in DEVONthink.

Check out the Tools > Inspectors > Annotations & Reminders inspector. The Annotations section will create an annotation file to make notes, etc. in. This is the first place I’d start.

You could could also use text formats like plain or rich text, Markdown, or potentially even sheets for such a purpose.