Skip to content

Instantly share code, notes, and snippets.

@d108
Last active August 29, 2015 13:57
Show Gist options
  • Save d108/9891026 to your computer and use it in GitHub Desktop.
Save d108/9891026 to your computer and use it in GitHub Desktop.
-- Copy a file into the currently selected note in Evernote as an attachment.
--
-- Usage:
--
-- osascript copyLastFileAsEvernoteAttachment.scpt
--
-- @filename copyLastFileAsEvernoteAttachment.scpt
-- @author Daniel Zhang (張道博)
-- Define the source path using a Mac OS type of path.
-- Example: drive-name:folder:subfolder
set myPath to "${MY_CUSTOM_AUDIO_PATH}"
set p to myPath as alias
tell application "Finder"
set latestFile to item 1 of reverse of (sort (get files of (p)) by creation date) as alias
set myFilename to latestFile's name
end tell
tell application "Evernote"
set theNote to selection
set theNoteTitle to (title of item 1 of theNote) as string
set theCreatedDate to (creation date of item 1 of theNote) as date
set noteItem to item 1 of theNote
tell noteItem to append attachment latestFile
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment