Description
Updated on July 17, 2013
This script exports an copy of selected DEVONthink items and saves them into Evernote, applying the Group Name in DEVONthink as a tag in Evernote. To use it, just highlight the items in DEVONthink that you want to send to Evernote and run the script!
Moving Items By Script Vs. Moving By Email
One fast way to get items into Evernote is simply to email them. Brett Kelly's eBook, "Evernote Essentials" provides a solid guide to how this works (See the chapter called "Evernote, Email and You") along with some other great email-related tips.
So why not just forward items to your Evernote email address? You certainly can -- but I think this approach is actually easier and also has a few additional benefits:
FASTER/SMARTER WORKFLOW. If you use Keyboard Shortcuts with this AppleScript, you'll have an workflow which is incredibly fast and makes it easy to stay organized! Personally, I use ⌘E to quickly send anything to Evernote. I can also tag and direct multiple items to a notebook by using a simple, fast dialog box instead of having to email them in one at a time (DEVONthink handles multiple items being forwarded by combining them into a single email). Trust me -- Archiving whole folders goes much faster when you don't have to send an email for every item!
PRIVACY Emailing an item into Evernote probably isn't an option if it contains sensitive information (or should you find yourself without an internet connection). This script moves things directly -- no internet connection required!
INSTALLATION
- On this page, click the link below "The Code" preview window which says "Click here to open it in your Script Editor". This will open the AppleScript inside your system's default AppleScript Editor application.
- You can save this script to DEVONthink's Script Menu or into your system's ~/Library/Scripts/ folder and launch it using the system-wide script menu from the Mac OS X menu bar. If you don't see the system script menu, it can be activated in the Preferences of the AppleScript Editor application. (You can, of course, save the script anywhere you like and run it manually!)
- To use, highlight the DEVONthink items that you want to copy into Evernote and run this script file.
- The "User Switches" at the beginning of the script allow you to customize the way it works. Take a look to familiarize yourself with the options I've put in for you!
FastScripts Keyboard Shortcuts (Optional)
Do yourself a favor and download FastScripts from Red Sweater. Triggering the script from the keyboard really supercharges the process -- you'll watch items practically fly into Evernote with a few keystrokes! Here's how you set it up:- Copy script or an Alias to ~/Library/Scripts/Applications/DEVONthink
- Set up your keyboard shortcut in the FastScripts Preference menu
For my FastScripts workflow, I am using ⌘ E (as in Evernote) for my global "Send to Evernote Shortcut". I use AppleScripts to move items from several programs into Evernote -- FastScripts can detect which program I'm in and pick the appropriate script to create the note. All I have to remember is ⌘ E!
HAVING TROUBLE? FIND A BUG?
The comment thread isn't a great way to report and diagnose individual bug reports or questions. Please click here to send a bug report directly to me.
TERMS OF USE
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
UPDATE NOTIFICATION
Follow Veritrope on Twitter to be notified of updates or fixes to this AppleScript.
The Code
http://veritrope.com
DEVONthink to Evernote Exporter
VERSION 1.5
July 17, 2013
// TERMS OF USE:
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
// LIKE THIS SCRIPT?
If this AppleScript is helpful to you, please show your support here:
http://veritrope.com/support
// IMPORTANT LINKS:
-- Project Page: http://veritrope.com/code/devonthink-to-evernote-export
-- FastScripts (Optional): http://bit.ly/FastScripts
// INSTALLATION:
-- You can save this script to /Library/Scripts/ and launch it using the system-wide script menu from the Mac OS X menu bar. (The script menu can be activated using the AppleScript Editor application).
-- To use, highlight the items you want to move into Evernote and run this script file;
-- The "User Switches" below allow you to customize the way this script works.
(Optional but recommended)
Easier Keyboard Shortcut with FastScripts
-- Download and Install FastScripts here:
-- http://bit.ly/FastScripts
// CHANGELOG:
1.50 Simplified handling of record type doesn't depend on localization anymore, is more flexible and supports all types including formatted notes. In addition, the error handling has been improved, e.g. in case of unsupported/too large files. (Christian Grunenberg)
1.40 BUG FIXES (CREATING NOTES FROM FILES), MISC. DIALOG TWEAKS
1.32 ADDED NOTE CREATION DATE TRANSFER
1.31 FIX FOR LONG TITLES (THANK YOU, WES COWLEY!)
1.30 TEMPORARILY REMOVED GROWL
1.22 INCORPORATED CHRISTIAN GRUNENBERG'S TAG FIX
1.21 TEMP WORK-AROUND FOR TAGGING ISSUE
1.20 MISCELLANEOUS CHANGES
1.10 FILE DETECTION AND OTHER BUG FIXES
1.00 INITIAL RELEASE
*)
(*
======================================
// USER SWITCHES (YOU CAN CHANGE THESE!)
======================================
*)
--CHANGE THIS TO DESIRED DEFAULT TAG
property defaultTag : "From DEVONthink Pro"
(*
======================================
// OTHER PROPERTIES (USE CAUTION WHEN CHANGING)
======================================
*)
property theNum : "0"
property EVnotebook : ""
property thename : ""
property theNotes : ""
property theBody : ""
property theURL : ""
(*
======================================
// MAIN PROGRAM
======================================
*)
tell application id "com.devon-technologies.thinkpro2"
set theNum to 0
try
set this_selection to the selection
if this_selection is not {} then
set EVnotebook to my Notebook_List()
repeat with this_item in this_selection
set theType to type of this_item
set theRichText to (the rich text of this_item)
set thename to (the name of this_item)
--LONG TITLE FIX (WES COWLEY)
if length of thename > 254 then set thename to (characters 1 thru 254 of thename) as string
set theURL to (the URL of this_item)
set theText to (the rich text of this_item)
set theSource to (the source of this_item)
set thePath to (the path of this_item)
set creDate to (the creation date of this_item)
set modDate to (the modification date of this_item)
if exists tags of this_item then
set theTags to (the tags of this_item)
else
set theTags to defaultTag
end if
set n to missing value
-- CREATE THE NOTE FROM ITEM
if theType is PDF document or theType is picture or theType is unknown or (theType as string) is "quicktime" then
tell application "Evernote" to set n to create note from file (POSIX file thePath) ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
else if theType is webarchive or theType is html or theType is formatted note or theType is sheet then
tell application "Evernote" to set n to create note with html theSource ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
else if theType is bookmark then
tell application "Evernote" to set n to create note from url theURL ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
else if theType is rtf or theType is rtfd then
tell application "Evernote" to set n to create note with text theRichText ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
else if theType is txt or theType is script then
tell application "Evernote" to set n to create note with text theText ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
else if theType is plist or theType is xml then
tell application "Evernote" to set n to create note with text (theSource as text) ¬
title thename ¬
notebook EVnotebook ¬
tags theTags
end if
if n is not missing value then
tell application "Evernote"
set source URL of n to theURL
set creation date of n to creDate
set modification date of n to modDate
end tell
else if theType is not bookmark and theType is not group and theType is not smart group and theType is not feed then
error "Couldn't export record "" & thename & ""."
end if
end repeat
end if
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
(*
======================================
// UTILITY SUBROUTINES
======================================
*)
--SORT SUBROUTINE
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end simple_sort
(*
======================================
// MAIN HANDLER SUBROUTINES
======================================
*)
--EVERNOTE NOTEBOOK SELECTION SUBROUTINE
on Notebook_List()
tell application "Evernote"
activate
set listOfNotebooks to {} (*PREPARE TO GET EVERNOTE'S LIST OF NOTEBOOKS *)
set EVNotebooks to every notebook (*GET THE NOTEBOOK LIST *)
repeat with currentNotebook in EVNotebooks
set currentNotebookName to (the name of currentNotebook)
copy currentNotebookName to the end of listOfNotebooks
end repeat
set Folders_sorted to my simple_sort(listOfNotebooks) (*SORT THE LIST *)
set SelNotebook to choose from list of Folders_sorted with title "Select Evernote Notebook For Imported Items" with prompt ¬
"Current Evernote Notebooks" OK button name "OK" cancel button name "New Notebook" (*USER SELECTION FROM NOTEBOOK LIST *)
if (SelNotebook is false) then (*CREATE NEW NOTEBOOK OPTION *)
set userInput to ¬
text returned of (display dialog "Enter New Notebook Name:" default answer "")
set EVnotebook to userInput
else
set EVnotebook to item 1 of SelNotebook
end if
end tell
end Notebook_List
Hi Justin.
Love the script.
Two questions (I’m not an expert script editor).
1. How do I modify the script if I want anything I export to go to one notebook in Evernote?
2. Is there a way to have the create/modified date metadata come over to Evernote?
Thanks!
Hi Andrew — Thanks for the kind compliment!
To answer in order:
… into something that has the Notebook name “hard-coded”, like:
Hi Justin,
i tried to use your script with DEVONthink Personal and tried to change the application id in the script to “com.devon-technologies.think2”. But then i see this error message: Syntax Error Expected “,” but found identifier. What am I doing wrong?
Mario
Try the 1.5 version above – hopefully that fixes you up! 🙂
Hi Justin — thanks for this script. It is working for many of my Devonthink files, but on some, I get a bunch of error dialogs — e.g.,
“There is no application set to open the URL evernote-html-snippet:///static//images/ […]”
I think the URL is the path to a component within a web clipping in DT. I can click ‘Choose Application’ and select Evernote, but that selection isn’t sticky… I get hundreds more dialogs. Any advice?
Thanks,
-Hankk
There have been many reports of this bug with a variety of Evernote AppleScripts recently… There is some code that can work around the error (see the Outlook to Evernote script), but I’ve been waiting to see if it gets resolved before adding it to all the other Evernote scripts.
I’ll certainly let you all know if I learn more about what is causing this…