Jump to content

Applescript to perform diff between two notes (compare conflicts)

Recommended Posts

I had a few conflicts between notes recently, so wrote an applescript to call an external diff tool, which saves having to export the notes.

It compares the XML version of the note (easy to change to HTML) since the lines in the contents.html note file seemed to be concatenated together. The XML file seem to be more consistent with number of lines.


The markup tags are still shown, but should still give an indication of the lines that changed. 

Hopefully an integrated diff tool might be include in Evernote at some stage  :)

(*Applescript to launch a diff tool to compare two notes in Evernote. Useful to compare conflicting notes1. Place the script file in ~/Library/Scripts/Applications/Evernote2. Ensure Applescript menu bar item is on. Option to turn on/off is under General Preferences in AppleScript Editor3. The variable difftool can be change to any command line tool you require*)-- opendiff launches FileMerge.app developer tool-- /Applications/Xcode.app/Contents/Applications/FileMerge.app set difftool to "/usr/bin/opendiff"--set difftool to "/usr/bin/visdiff"tell application id "com.evernote.Evernote"    try        set selected_notes to selection        if (count of selected_notes) = 2 then            set firstNoteId to my getNoteId(local id of (item 1 of selected_notes))            set secondNoteId to my getNoteId(local id of (item 2 of selected_notes))            set evernoteLibPath to (POSIX path of (path to library folder from user domain as string)) & "Application Support/Evernote/accounts/Evernote/"            set evernoteUserid to name of (get current account)            set contentPath to evernoteLibPath & evernoteUserid & "/content/"            -- Noticed HTML file may be identical content, but some lines might be joined together on single long lines,             -- so compare Evernote enml XML data file instead            do shell script difftool & " '" & contentPath & "/" & firstNoteId & "/content.enml' '" & contentPath & "/" & secondNoteId & "/content.enml'"        else            display alert "Compare Two Notes:" message "Please select only 2 notes to compare"        end if    on error error_message number error_number        display alert "Compare Two Notes: ERROR" message "Error running script (" & error_number & ") : " & error_message as warning    end tryend tellon getNoteId(note_id)    set AppleScript's text item delimiters to "/"    set the id_items to every text item of note_id    set AppleScript's text item delimiters to ""    return last item of id_itemsend getNoteId

I've also placed it on Github Gist https://gist.github.com/hooli/7699092




Link to comment
  • 1 year later...
  • Level 5*



thanks for sharing a great tool!


Do you know where I can get the file difference tool you used, FileMerge.app ?


I have done a Google search but can't find it.



Link to comment


This topic is now archived and is closed to further replies.

  • Create New...