Jump to content
  • 0

(Archived) exporting contents of a single note to a .txt file for display in GeekTools



Hi, newbie AppleScript question:


I'd like to export the contents of a single designated note to a plain text file.


(With GeekTools I'll then display that file on my desktop.)


For selecting the designated note, the Evernote note that contains my to do hot list has a unique tag that no other notes use.


I've searched and found some lengthy AppleScripts on the forums for much more complex operations -- such as exporting many notes to RTF or HTML in subfolders -- but my attempts to modify them haven't been successful and the Evernote AppleScript dictionary contains only the commands and no examples of implementation / no tutorials.


Evernote says they don't support helping premium users with this type of simple programming but suggested maybe someone in the developer forums might help. Hoping someone either has specific code or can give me some links to tutorials / examples that are very simple for selecting a specific note, selecting it's contents, writing this to a file, etc.





Link to comment

8 replies to this idea

Recommended Posts

Welcome to the forums and welcome to AppleScripting. I was right where you are only a few months ago, so I know the feeling. On your larger search for Evernote Applescripting help and tutorials, here are a few resources that really got me off the ground:

http://veritrope.com/code_type/evernote/ -- has a great collection of Evernote specific AppleScripts with fantastic commentary in-line. Veritrope (Justin) is a bit of a genius when it comes to Applescript and specifically Evernote. Def study some of his scripts and get a feel for how he manipulates Evernote. 

http://dev.evernote.com/documentation/local/chapters/mac.php -- this is a sample Applescript for Evernote that shows how the main terms in the Dictionary can be used. Very helpful for the basics and the syntax. 


As for your specific request, check out this script by Veritrope -- http://veritrope.com/code/evernote-get-plain-text-of-selected-note/


It uses shell scripting, but it gets the job done, so you don't need to fully understand how the shell script works. 


Finally, to write that plain text to a new text file, here's a simple script for Mac's TextEdit (using the plain_Text variable from Veritrope's script):

tell application "TextEdit"

set newDoc to make new document with properties {text:plain_Text}
end tell


Hope that helps, and let me know if you have any further questions, 

Link to comment

If you use the referenced script, you can just change the final shell command to:


set plain_Text to do shell script "echo " & quoted form of the_HTML & space & "textutil -format html -convert txt -stdin -output '/Users/yourname/Desktop/output.txt'"
Adjust the path at the end to wherever you want the file to be saved.
Link to comment

Thank you, both! Just had a spare few hours to try this out -- had some trouble with selecting the note, took a few hours.


Here is the final tested version of an AppleScript that works and below that the Geek Tools directions (which also took me a while to figure out, one needs osascript):



tell application "Evernote"

set the_Selection to find notes "tag:todo"

set the_HTML to HTML content of (item 1 of the_Selection)

set plain_Text to do shell script "echo " & quoted form of the_HTML & space & "| textutil  -convert txt  -stdin -output '/Users/myusername/Documents/ToDo.txt'"

end tell




1. Evernote must be running.


2. the tag "todo" is unique to this note


3. the above script was created in Applescript then saved in Applications as ToDoToTXT.scpt


4. in Geektools, drag a Shell, and then from a text editor paste in the following two lines for the Command:



osascript /Applications/ToDoToTXT.scpt
cat /Users/myusername/Documents/ToDo.txt
5. set to refresh periodically (I have every 180 seconds)
Now I can edit / maintain a todo list in Evernote, and have it automatically display on my Mac desktop as plain text.
Link to comment
  • Level 5

1. Evernote must be running.


If you add 'activate' as the first line inside the tell block, Evernote will be launched automatically.

You will still need Evernote to be running at compile time.

Link to comment

If you add 'activate' as the first line inside the tell block, Evernote will be launched automatically.


Thanks, but FYI this turns out to creates quirky behavior in GeekTools -- as I have the GeekTools shell refreshing (running the script) every few minutes, having Activate in there causes Evernote to come to the front and if I am working on something else then I'm accidentally typing in Evernote. Especially problematic if I have a keyboard maestro macro running at the time in another application.


If I add an AppleScript commands to hide Evernote from finder, then next time GeekTools refreshes it minimizes Evernote -- a problem if I was actually in Evernote deliberately working on something when GeekTools auto-refreshed.


It was even more problematic when in GeekTools and modifying shell location / font with Open Preferences -- GeekTools activates the script (refreshes) every time one clicks on the shell window to make an adjustment -- thus running the script and with Activate shifting focus from GeekTools to Evernote and making adjustments impossible without quitting Evernote or editing the script to remove the Activate command from the AppleScript and recompiled.


I know very little programming but if there is a way to make Activate conditional in AppleScript (conditional only if Evernote is not already running), that would be a good solution?

Link to comment
  • Level 5

How about something like this:

tell application "System Events"	set processList to (name of processes)end tellif processList does not contain "Evernote" then	tell application id "com.evernote.evernote"		activate	end tellend if

I used

tell application id "com.evernote.evernote"

because if you use

tell application "Evernote"

when evernote is not running, applescript will send the messages to EvernoteHelper instead.

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...