Scan + Rename + tag + evernote - typing = happiness

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

I have a workflow that the end goal is to get the file in two places, evernote and a folder in my drobo, while getting a proper name and getting openmeta tags and get tagged in evernote without typing at all. If I have to type I don't do things like give good file names and tag. So that was my mission.

The tags were the tricky thing to figure out. I wanted to both apply the tags to both evernote and openmeta. But there is more. I wanted to predefine some tags that would always go in this type of document. I also wanted to add the PDF keywords as tags. (snapscan adds pdf keywords if you highlight the words with a highlighter)

Lots of pain and suffering because of my applescripting ignorance. But here is what I got.

First you need this software other then Hazel:
    Textautomator Action Pack

Here is how I did it.

If all of the following conditions are met

Kind is PDF
Contents contain (what ever will identify the document, like using "home depot" with "total" will tell me it is a home depot receipt)
Date Created is not in the last 2 minutes (this give the ocr software time to do its stuff)

Do the Following (this has to be done in the right order)

Rename file with pattern name_(what ever text you want to enter)Extension -- (the name given my snapscan is the date starting with the year and going all the way down to the secound)

Run Automator workflow (This takes the pdf keywords and puts them in the clipboard. The applescript to do this was way above my head.)
    Here is that workflow
    -Get Specified Finder Items
    -Get PDF metadata (only keywords checked)
    -get paragraphs of text (it wouldn't work without this one not sure why?)
    -find and replace in Text (Find: is set to a space. Replace: is set to a comma with now spaces. Having spaces made evernote freeze up)
    -Change Case of Text (I set it two lowercase becouse sometimes ocr puts capital letters in strange places)
    -Copy to Clipboard

Run applescript You can add any desired tags you always want to be with this type of text with the first line of code between the commas, but don't add any spaces before or after the commas. The pdf keywords in the clipboard will be added to the list of tags in the first line.

Code: Select all
set otherTag1 to "blue,big,another stupid tag,purple suit"
-- can change the tags but leave no space between commas
set theClipboard to the clipboard
-- clipboard contains pdf keywords extracted from automator action

   set oldDelims to AppleScript's text item delimiters -- save their current state
   set AppleScript's text item delimiters to {","} -- declare new delimiters
   set delimitedList1 to every text item of otherTag1
   set delimitedList2 to every text item of theClipboard
   set delimitedList to delimitedList1 & delimitedList2
   -- this combines the the tags from clipboard with those in the apple script
   tell application "Evernote"
      create note from file theFile tags delimitedList
   end tell
   tell application "Tags"
      apply to files theFile tags delimitedList
   end tell
   set AppleScript's text item delimiters to oldDelims -- restore them
   set AppleScript's text item delimiters to oldDelims -- restore them
on error
   set AppleScript's text item delimiters to oldDelims -- restore them in case something went wrong
end try

Move file to folder (where ever you want it. I archive it to a folder on my drobo and my drobo also gets a offsite backup)

Well thats it. I have the pdf renamed in a relevant manner; it is in evernote tagged and it is on my drobo tagged. No typing required. I only do this for paper documents or receipts I get often. I rename other things with the highlighted keywords found by the ocr software.

I hope this helps someone.
Posts: 26
Joined: Wed Aug 03, 2011 11:50 am

Return to Tips & Tricks - DO NOT POST QUESTIONS