Blog » Mac Automation

Category: Mac Automation

OCR Research with PDFPen and Hazel

 

hazel-hero

 

I have a lot of productivity apps that I use, perhaps my vice. But still, I can get work done quickly and efficiently. Here’s my setup to OCR pdfs I find on the internet and import them automatically to my reference managers of choice.

What you need

  1. Hazel
  2. PDFPen
  3. Papers
  4. (Optional) DEVONthink Pro
  5. AppleScript

How it works

  1. Open Hazel Preference Pane and click the plus in the bottom right corner to add a folder to watch. Click the plus in the window next to that to add a rule. You can name it OCR My Research or whatever you like.
  2. Name your rule. Then follow these steps:
    1. Choose “If ‘all’ conditions are met”
    2. Choose “Kind” is “PDF”
    3. Then below choose “Do the following to the matched file or folder: “Run AppleScript”. Choose the embedded AppleScript and paste this in
tell application "PDFpen"
    open theFile as alias
    tell document 1
        ocr
        repeat while performing ocr
            delay 1
        end repeat
        delay 1
        close with saving
    end tell
    tell application "PDFpen"
        quit
    end tell
end tell

Next, choose “Open” in application “Papers”. Do the same when choosing your next condition only open in DEVONthink.

    1. (Optional) I like to move my pdfs once I’ve OCR’d them and have imported them into my databases. I have Research folders all over my Mac as our school uses Box.com for a storage provider. I also use Dropbox and iCloud Drive for important documents and use a nifty AppleScript to keep them in sync. Anyway, the next thing I do is move the PDF after Hazel opens it in the two apps. Choose “Move” to folder “Whatever your folder name is”.

Thanks to Katie Floyd of Mac Power Users for the modified AppleScript. All in all, your setup should look something like this:Screenshot 2015-08-25-3