Skip to content

Instantly share code, notes, and snippets.

@n8henrie
Last active November 21, 2016 17:25
Show Gist options
  • Save n8henrie/2c653df618e63d320ec2 to your computer and use it in GitHub Desktop.
Save n8henrie/2c653df618e63d320ec2 to your computer and use it in GitHub Desktop.
Hazel script to import files with OSX tags to Evernote and preserve tags
-- Find original post here: http://n8henrie.com/2012/06/converting-openmeta-tags-to-evernote/
-- set theFile to alias "Path:To:Your:Test:File" -- uncomment this line for testing in Applescript Editor!
local targetNotebook, the_tags
--Which notebook do you want the notes to end up in? **Case Sensitive**
set targetNotebook to "Inbox"
set the_tags to paragraphs of (do shell script "mdls -raw -name kMDItemUserTags " & quoted form of POSIX path of theFile & " | sed 's/^[()]$//g' | ruby -ne 'each = $_.strip.end_with?(\",\") ? $_.strip[0...-1] : $_.strip; puts each if each != \"\"'")
-- Debug
-- choose from list the_tags
tell application "Finder"
set createdFileDate to (the creation date of (theFile as alias))
set modFileDate to (the modification date of (theFile as alias))
end tell
tell application "Evernote"
launch
set theItem to create note from file theFile notebook targetNotebook tags the_tags created createdFileDate
set (modification date of theItem) to modFileDate
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment