Macs in Chemistry

Insanely great science


Export Notes to Evernote

I had an interesting email from Geoff Hutchison who is using an iPad mini for taking notes using Notability the notes can be typed, handwritten using a stylus, or images. Notability does not export directly to Evernote an app that can capture and synchronise notes between multiple platforms including iPad and desktop. The other feature that makes Evernote interesting is it provides handwriting recognition, thus making the handwritten notes text searchable.

Geoff had a Automator service that imported the Notability notes that had been saved to Dropbox into EverNote, however he wanted a better way to name the notes created in Evernote. As it turned out the best way to do this was to use Applescript.

The Automator Service

The workflow is shown below, the first part converts each page of the PDF to a PNG image and provides them as an input for the Applescript, after import the PNG images are then moved to the Trash.


The Applescript

The aim of the script is to create a Note in Evernote using the name of the imported file as the name of Note.

The first part of the script identifies the file to be imported and gets the POSIX path to the file as a text string, we then use “/“ as the delimiter and identify the last item in the string which will be the filename, then we remove the file extension.

The next step displays a dialog box containing the proposed filename that will be used for the Note, the user has the option at this stage to change the name.

Finally we script Evernote to create a new blank note with the correct title, we then import the png files into the note.

Once imported Evernote will synchronise the new Note and perform handwriting recognition.

on run {input, parameters}

    set theFile to item 1 of input
    --display dialog theFile
    set thePosixPath to POSIX path of theFile as text
    --display dialog thePosixPath
        set text item delimiters to "/"
        set the_filename to last text item of thePosixPath as text

        set text item delimiters to ""
  on error
      set text item delimiters to ""
  end try
    set the_offset to offset of "." in the_filename
    set my_filename to (characters (1) thru (the_offset - 1) of the_filename) as text

    display dialog "Note name" default answer my_filename buttons {"Cancel", "Create"} default button 2
    copy the result as list to {text_returned, button_pressed}

    set my_filename to text_returned

    --display dialog my_filename

    tell application "Evernote"
      --set my_filename to item 1 in input
        set new_note to create note with text "" title my_filename notebook "Import"
        repeat with SelectedFile in input
              tell new_note to append attachment SelectedFile
          on error errMessage number errNumber
                if the errNumber is equal to 4 then
                  -- The file being imported is not supported
                    set userCanceled to false
                      display dialog "Your Evernote account does not support the import of this type of file.  Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution
                  on error number -128
                      set userCanceled to true
                  end try

                    -- If the user wishes they can be taken to the Evernote premium upgrade page
                    if userCanceled is false then
                      tell application "Safari"
                            open location ""
                      end tell
                  end if
                  -- Unspecified failure
                    display alert "Import into Evernote failed" message "Error(" & errNumber & "): " & errMessage as warning
              end if
          end try
      end repeat
  end tell

    return input
end run

The resulting workflow needs to be saved in username/Library/Services, once this is saved if you right-click on a PDF file and choose the “Services” menu you should be able to select the “Export to Evernote” service


You can see how this might be modified to accommodate photographs taken of posters, messages sent via iMessage or email etc. You could also use this service as a folder action attached to a specific Dropbox folder, and have different Dropbox folders then upload to specific notebooks within Evernote.

Last Updated 30 January 2013