Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Update/create notes in Evernote for files in a directory that have been modified since last run.
to updated_files()
# customization variables
set _nvalt_path to "/Users/gabe/Dropbox/Notational Data"
set _last_run_files to "/Users/gabe/Dropbox/.nvalt_to_evernote_last_run_at"
# don't edit anything below here
set _change to do shell script "echo `date +'%s'` - `cat " & _last_run_files & "` | bc"
set _find_query to "find '" & _nvalt_path & "' -mtime -" & _change & "s | grep \"\\.\\w\\+$\""
do shell script "date +'%s' > " & _last_run_files
return paragraphs of (do shell script _find_query)
on error
return {}
end try
end updated_files
to update_evernote from _filenames
tell application "Evernote"
set _notebook_name to "nvAlt"
repeat with _filename in _filenames
set _title to do shell script "filename=`basename " & (quoted form of _filename) & "`; echo ${filename%.*}"
set _query to "notebook:nvAlt intitle:" & _title as text
set _notes to find notes _query
set _content to do shell script "/usr/local/bin/multimarkdown '" & _filename & "'"
if (number of _notes) is 0 then
set _note to create note from file _filename notebook _notebook_name
set _note to the first item in _notes
end if
tell _note
set HTML content to _content
end tell
end repeat
end tell
end update_evernote
on run (_filenames)
if the number of _filenames is 0 then
set _filenames to updated_files()
end if
if the number of _filenames is not 0 then
update_evernote from _filenames
end if
end run

The AppleScript compile fails in line 23 with an error


Missed line 1. Explains the error. Fixed now. My user error.


Hey Gabe— Does this work with nvAlt in plain text file storage mode (as opposed to single database)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment