Let Hazel or DT put tag automatically

In order to see if a file has been OCR’d with the DT’s ABBY Fine Reader Engine outside DT I let Hazel put automatically put a label on the file, if it has been OCR’d with the ABBY Engine.

Now that my files are in DT I would like to know if there is a way to let Hazel or DT or Automator or whatever…, put automatically a tag within DT if the file matches some determined condition (for example: OCR’ed with Abby, that is to say, it meats the condition: “Content Creator starts with DEVONthink Pro Office”).

Hazel cannot safely work on folders inside your database package, unless you want to risk mangling your databases.

The solution would be a script, which is very feasible. And you can use Automator to run scripts, so that would be another option.

Just curious: why does this matter? It’s not something you can do anything about, once you’ve OCRd a PDF.

Hmmm, I 'm not so good at scripts. Would you know any script to start with and tweak it later?

I want to be sure that every file that enters DEVONthink has the ABBY OCR.

Parts of the “outside-DevonThink” Hazel automation-structure and script(s) to be found here, especially Step 2, may be helpful to you. The AppleScript that identifies previously OCR’d PDFs looks interesting. But please note that I’m an AppleScript tyro, I cannot vouch for the functionality of the scripts, they are nearly two years old and there are amendments further down the thread.

This script will create a tag for each selected document that contains the contents of that document’s kMDItemCreator metadata – if such an element exists for that document. (I.e., it will fail silently for most documents that are not PDF or PDF+Text)

tell application id "DNtp"
	set theSelection to the selection as list
	repeat with thisItem in theSelection
		set myMD to the meta data of thisItem
			set theCreator to (kMDItemCreator of myMD) as string
			set the tags of thisItem to the tags of thisItem & theCreator
		end try
	end repeat
end tell

Use this by selecting multiple documents (do not select groups) and running the script. Instructions for using scripts are found in the manual, Help, and all over the internet.

If you run this against a passel of PDFs and then look at your tags you’ll see which ones came from which creator.

Thank for your help Hugh & form.

I think I will try to do this outside DEVONthink. Me too: Apple Script tyro :laughing: .