Print to DEVONthink or using Service menu to import auto-OCR

Hello. Is there a way when either using the Print command to import into DTPO or when using the Service menu, for the imported PDF to auto-OCR (PDF + Text)?

Here’s what I’ve tried: If I receive an email with a PDF attached, and left click the attachment and have DTPO import, all I get is a PDF. If I open the PDF attachment in Preview and then use the print > Save PDF to DEVONthink Pro, same thing; only end up with a PDF that has to then manually be converted.

Be awesome if there is a way to execute any of these commands, and DTPO would auto-OCR.

I can’t seem to find any setting in Preferences (but maybe I’m missing something).

Thank you for the assistance.

If you have installed the Folder Action Scripts in DEVONthink > Install Add-Ons… then you can add the DEVONthink - Import, OCR, and Delete folder action to any folder in Finder via the Finder Services menu. (A one-time setup.) Print a PDF and save (via the Print dialog) to that folder. It will be imported to DEVONthink per the Import Settings in Preferences. The file will be OCRd. The non-OCR original will be deleted from DEVONthink.

Hi Korm! Thanks so much for the assistance; I really appreciate it. That worked really well. Thank you again. Have a nice week.

A follow up: Is there a way to delegate or choose which group the incoming file goes? Currently, the imported file goes in the global inbox, necessitating my having to move it manually. I’m eager to have this be an auto-pilot thing, as it is a simple import, ocr, and store; I already know what the file is and therefore just want to store it for future reference.

Thanks for your reply Greg_Jones. :slight_smile: I think I’m missing something here. I followed the directions in the Help menu “Select group: A group selector is shown that lets you choose the destination. The group selector appears as a black panel floating on top of all other windows.”

Unfortunately, I’m not seeing that black panel that gives me the choice to choose a group. I’ve attached a screenshot. All I’m seeing is the Import options. Thanks so much for the assistance!

You are correct-I’m seeing the same thing. The import respects the preference if set to Global Inbox or Inbox of current database, but the Select group option sends the document straight to the Global Inbox. I really can’t think of anything to do differently.

I checked both the help manual and even Take Control of Getting Started with DEVONthink by Joe Kissell; it appears the program is supposed to be able to do this. Is this a known bug?

This is a far more complicated process than you imagine (and something people may use a util like Hazel for).

It is not a bug. The Folder Action is hardwired to file things in the Global Inbox - the safest bet since it is always available.


My experience is that Select Group is the only preference that is ignored. The folder action does respect the preference to import to the inbox of the currently selected database. Seems like any restriction at all is unnecessary, as the preference to select a group will only present available groups, and since the Global Inbox is always available…

Here is a modified version of “DEVONthink - Import, OCR, and Delete”. Open Script Editor and paste the code, below. Compile and save as a new document (with a different name) in ~/Library/Scripts/Folder Actions. You need to go through the process mentioned above to attach this script as a folder action to a new triggered folder.

This version will require DEVONthink to open the group selector. It is NOT guaranteed to work because OS X occasionally either ignores items added to triggered folders, or neglects to tell DEVONthink about every item added. Best to add a single to a triggered folder, let the script complete for that item (i.e., you tell it where to save something) and then add the next item.

-- DEVONthink - Import, OCR & Delete.applescript
-- Created by Christian Grunenberg on Fri Jun 18 2010.
-- Copyright (c) 2010-2014. All rights reserved.

on adding folder items to this_folder after receiving added_items
		if (count of added_items) is greater than 0 then
			tell application id "DNtp" to launch
			repeat with theItem in added_items
				set lastFileSize to 0
				set currentFileSize to 1
				repeat while lastFileSize ≠ currentFileSize
					delay 0.5
					set lastFileSize to currentFileSize
					set currentFileSize to size of (info for theItem)
				end repeat
					set thePath to theItem as text
					if thePath does not end with ".download:" then
						tell application id "DNtp"
							-- set theRecord to ocr file thePath to incoming group
							set theRecord to ocr file thePath to display group selector
							if exists theRecord then tell application "Finder" to delete theItem
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

Neither this script nor the original provided by DEVONtechnologies includes error handling – when failing, it fails silently.

Thanks Korm for the snippet of code :smiley: I will try this.

BLUEDOG, you mentioned using Hazel above. I was unaware that this will work with DTPO. Have you had good experience using this app (or has anyone else)?

Re: Hazel – browse the forum. There are dozens of threads on this topic.

And also regarding Hazel - it’s not a tight integration by design (ie. we’re not hooking into Hazel, nor it into DEVONthink). However, due to Hazel’s Execute Script capabilities and our robust Applescript dictionary, there are inter-application opportunities between them. Cheers!

Thank you to everyone for your assistance and suggestions, and Korm and BLUEDOG, the thoughts on Hazel! :slight_smile: Have a great rest of your work week.

You as well.

PS: It’s BLUEFROG :mrgreen: