Safari URL to Specific Evernote Notebook with Tags


Sends the URL of the top tab displayed in Safari to Evernote with a "hard coded" notebook name and tag list. NOTE: This does not pull Evernote to the foreground, and so does not need any further interaction. This is for quickly collecting URL's for a specific research project, and simulates Yojimbo's Tag Collection feature, but without necessarily requiring the mouse. Don't you hate mouse shoulder? I recommend using FastScripts from Red Sweater, or creating an Automator Service, so you can assign a keyboard shortcut. Personally I like stuff like CTL+OPT+CMD+x I create a new one, as needed, for each project. Works for me as I seldom have more than a couple of projects requiring this type of action on at the same time.

The Code

-- This is my attempt to simulate Yojimbo's tag collections with Applescript and Evernote.
-- This is as simple as I could make it.
-- v1.0 ...cb

-- Proper use of this script is to duplicate it for each project, and launch it using
-- something like FastScripts from Red Sweater

-- In other words, this script will just slam a note into the specified notebook with
-- the specified tags.  Tags and the notebook will be created without confirmation, if
-- they don't already exist.

-- NOTE: The contents of the clipboard will be used as the body of the note,
-- so remember what you had in the clipboard last, or clip (CMD+C) what you
-- want to appear in the body of the note.  Evernote will use whatever is in
-- the clipboard - text, image, entire Web page, whatever.

-- GTD Note: The Evernote mail syntax uses the @ to prefix notebook names,
-- so I renamed my @Inbox to _Inbox...  just so you know.

set notebookName to "_Inbox" -- what notebook are we using
set tagList to {"Applescript", "Evernote"} -- what tags do we want

-- Get useful information from current tab of current Safari window
tell application "Safari"
    set safariWindow to window 1 -- need an object reference to Safari
    set tabURL to (URL of current tab of safariWindow) -- Safari shows Web pages in tabs, so get the URL of the tab
    set tabName to (name of current tab of safariWindow) -- Get the name of the tab
end tell

-- Create a new note in Evernote with the information collected above.
tell application "Evernote"
    set newNote to create note title tabName from url tabURL notebook notebookName tags tagList
end tell