Last active
August 27, 2021 22:40
-
-
Save lpar/ad4a55e42e9720d834ae1fd933b68d38 to your computer and use it in GitHub Desktop.
AppleScript droplet to file documents into specific Evernote notebooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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