Category: organization

Scanned Automation with Hazel, Revisited

You may recall I was scanning documents and using Applescript to extract a highlighted date from them. Since then, Hazel has started natively supported date matching in its rules, which has been great. Tell Hazel the date format and maybe some text just before or after it os it can tell start date from end date, and it gets it right. Most of the time. 

Sometimes, though, things go sideways. I can see the text in the document, but for whatever reason, Hazel isn’t matching. I ended up creating a service via Automator which extracts the text from the PDF and puts it up on the screen. Most times, I can then find the text I want and put it into the Hazel rule, and away we go. 

This project is why I hadn’t posted much the past few weeks – I’ve been running a backlog of scanned PDFs through a bunch of rules to make sure I’ve got enough of it covered. Right now, I’ve got about 40 rules to identify the company that sent me the bill, and another slightly-less than that to identify the dates. 450 items have gone through the process, so I’m fairly confident that it’s working. A few more tweaks – tagging for things like “bills that aren’t automatically paid online” and watching for social security numbers, and I should be in good shape. 

Importing Mavericks Tags to Evernote

I have a Hazel-based workflow defined for scanned documents. With the release of Mavericks, I added tagging to that flow for things like the company that generated the document, a few tags about what the doc is about (cars, kids, etc). However, I like keeping the docs in Evernote. So, as I usually do, I turned to Applescript and came up with this:

set theActualFile to choose file

set theFile to quoted form of (POSIX path of (theActualFile))

set origDelim to AppleScript’stext item delimiters

set newDelim to “,”

set AppleScript’stext item delimiters to newDelim

— Get tags from file

set userTags to (do shell script “mdls -raw -name kMDItemUserTags ” & theFile)

set theTags to (every text item of userTags)

tell application “Evernote”

set theNote to create note from file theActualFile

–Clean up the list, removing whitespace, quotes, parenthesis, tabs, newlines

repeat with theTag in theTags

— sed command in line below taken from stib’s answer on this page:

set theTag to do shell script “echo ” & quoted form of theTag & “| tr -d ‘\n'”

set theTag to do shell script “echo ” & quoted form of theTag & “| tr -d ‘\r'”

set theTag to do shell script “echo ” & quoted form of theTag & “| tr -d ‘[:blank:]'”

set theTag to do shell script “echo ” & quoted form of theTag & “|sed \”s/[^[:alnum:][:space:]]//g\””

— TODO need to clean out newline as well

if not (tag named theTag exists) then

set my_new_tag to (make new tag with properties {name:theTag})

assign my_new_tag to theNote


assign tag theTag to theNote

end if

end repeat

end tell

set AppleScript’s text item delimiters to origDelim


The workflow asks for a file to be chosen (I’ll fix that so it accepts a file argument later when I’m ready to make it a part of the automated flow), gets the tags as string (via mdls), splits it out, and then strips out the newlines, tabs and whitespace from each of the tags.

Two caveats.

1) I assume it will split apart any tag with a comma in it.
2) It will remove whitespace form inside the tag as well – so a tag of “credit card” will become “creditcard”… but I’m okay with that.

Here’s the Applescript for your downloading pleasure: Import File to Evernote.scpt

Off The Secret Weapon, Back to Remember The Milk

That was fast. 

Unfortunately, I pretty quickly remembered what I didn’t like about The Secret Weapon. Because it’s within Evernote, it was always multiple steps to add a task, multiple steps to see what’s on my list, and multiple steps to make sure I was only looking at my 1-Now list instead of everything. And I never felt confident that I was getting everything into view. 

I did scan all the business cards I’ve gotten and held on to into Evernote though. So now I can take a bunch of folks out of my contacts list – people I’ve met, good to have handy but don’t need to be clogging up the Address Book.

I’m finally starting to get Evernote. Kind of. For me, it’s to notes what Dropbox is to files – always around, synced on all my devices. I think with a bit of tinkering I can get it into my workflow. 

Next up, some good old fashioned automation. 

Starting with The Secret Weapon and Evernote

I decided it was time to go all-in with Evernote. I’ve been toying around with it here and there and trying to figure out how it would fit into my workflow. I had been using Remember The Milk, and while it worked, it never felt quite right. I had read about The Secret Weapon, a GTD process built on Evernote, and tried it once before, but had dropped it because of two perceiving missing items. One was location based reminders, which I could get with RTM’s app, and the other was an easy way to handle recurring tasks without cluttering up my to do list. 

As it so often turns out, I didn’t actually need the location based reminders. So how could I get recurring tasks? Hm. IFTTT could write to Evernote. So now I just needed to figure out how to trigger IFTTT at the right time. If it was just one or two tasks at predictable times, I could probably use the Date & Time trigger. But I want something flexible so I don’t need to create recipes for each task. FInally, it dawned on me. Create entries in Google Calendar, put “[todo]” in the event description, and create an IFTTT trigger for events matching a search to write into my Evernote notebook. 

I guess we’ll know if it works on Friday when I need to clean the litter box.