Skip to content

Instantly share code, notes, and snippets.

@lpar
Last active August 27, 2021 22:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpar/ad4a55e42e9720d834ae1fd933b68d38 to your computer and use it in GitHub Desktop.
Save lpar/ad4a55e42e9720d834ae1fd933b68d38 to your computer and use it in GitHub Desktop.
AppleScript droplet to file documents into specific Evernote notebooks
-- Source code of an AppleScript droplet to file documents into specific Evernote notebooks
-- If you just want to run the code, download the DMG file
--
-- Get notebook name from name of droplet
-- See https://stackoverflow.com/questions/5770384/how-find-the-file-name-of-an-executing-applescript
on getMyName()
local myName, tidSaved
tell application "System Events"
set myAlias to path to me -- alias to the file/bundle of the running script
set myName to name of myAlias -- filename with extension, if any.
if name extension of myAlias is not "" then -- strip away extension
set {tidSaved, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {""}}
set myName to items 1 through -(2 + (length of (get name extension of myAlias))) of myName as text
set AppleScript's text item delimiters to tidSaved
end if
end tell
return myName
end getMyName
-- Send drag-dropped files to Evernote, filing them in the appropriate notebook,
-- then moving each one to the trash
on open theDroppedItems
set nbname to getMyName()
repeat with a from 1 to length of theDroppedItems
set theCurrentDroppedItem to item a of theDroppedItems
set fileAlias to theCurrentDroppedItem as alias
tell application "Finder"
set fname to name of theCurrentDroppedItem
end tell
tell application "Evernote"
create note title fname from file fileAlias notebook nbname
end tell
tell application "Finder"
move fileAlias to trash
end tell
end repeat
end open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment