Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Clip to Evernote via Quicksilver and AppleScript Apps
The latest release of Evernote includes very straightforward AppleScript support. Hopefully someone will build an Evernote plug-in for Quicksilver, but in the meantime here is a script for clipping text directly from Quicksilver into Evernote:
(*

Clip to Evernote for Quicksilver, by Jed Verity junk@veritys.com

INSTALLATION

1. Put this script in ~/Library/Application Support/Quicksilver/Actions/
2. Restart Quicksilver

CONFIGURATION

Set default values in the "defaults" property below.
	- Tags must be separated by spaces (so multiple word tags would not work)
	- Notebooks and tags are case-sensitive. If it doesn't match properly it won't work at all.
	
USAGE

When you have text in your first Quicksilver pane, select "Clip to Evernote" (or whatever you call this script if you change the name).

The text format is as follows: You must have a title or note (or both), but everything else is optional. 

title:your note here nb:notebook tags:space-separated tags here

The only thing that matters is that any specified notebook or tags must come after title and note.

EXAMPLES

1. this is a note with no title or anything

	- creates note with your default title, notebook, tags, if specified, otherwise just goes straight into Evernote as is
	
2. todo:buy batteries

	- creates note with title "todo" and note "buy batteries"

3. remember to buy batteries: tags:todo household

	- creates note with title "remember to buy batteries" and tags "todo" and "household"
	
4. great idea for meeting: tell everyone to put 20% of salary in mattress nb:Work tags:meeting finance meltdown

	- creates note "tell everyone to put 20% of salary in mattress" with title "great idea for meeting" in notebook "Work" with tags "meeting", "finance", and "meltdown"

*)

property defaults : {notebook:"", tags:"", title:""}
property special_delim : ";"

global txt, pspecial, cpos

--my mainprogram("")

using terms from application "Quicksilver"
	on process text qtxt
		my mainprogram(qtxt)
	end process text
end using terms from

on initvars(qtxt)
	copy qtxt to txt
	set pspecial to 10000000
end initvars

on mainprogram(qtxt)
	my initvars(qtxt)
	set ztags to getdata("tags:", defaults's tags)
	set znotebook to getdata("nb:", defaults's notebook)
	set ztitle to gettitle()
	if pspecial < txt's length then
		set pend to (pspecial - 2)
	else
		set pend to txt's length
	end if
	set znote to getnote(pend)
	set ztags to itemize(ztags, " ")
	--return {ztitle, znote, znotebook, ztags}
	my CreateEvernote(ztitle, znote, znotebook, ztags)
end mainprogram

to CreateEvernote(t, n, nb, tg)
	tell application "Evernote" to create note with text n title t notebook nb tags tg
end CreateEvernote

to getdata(label, default)
	set o to offset of label in txt
	if o > 0 then
		if o < pspecial then
			set pspecial to o
		end if
		set chunk to my trim(itemize(txt, label)'s item 2 as string)
		if label = "nb:" then
			set nxt to "tags:"
		else
			set nxt to "nb:"
		end if
		set chunk to my trim(itemize(chunk, nxt)'s item 1 as string)
		if (offset of special_delim in chunk) is not false then
			return itemize(chunk, special_delim)'s item 1
		else
			return chunk
		end if
	else
		return default
	end if
end getdata

to getnote(meta_start_pos)
	try
		set start_pos to cpos + 1
	on error
		set start_pos to 1
	end try
	if start_pos > meta_start_pos then
		return ""
	else
		return my trim(text start_pos thru meta_start_pos of txt)
	end if
end getnote

to gettitle()
	set title to my getdata("title:", defaults's title)
	if title = "" then
		set cpos to offset of ":" in txt
		if cpos > 0 then
			set title to my trim(text 1 thru (cpos - 1) of txt)
		end if
	end if
	return title
end gettitle

to itemize(var, delim)
	set delims_old to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delim
	if var's class = list then
		set txt_new to var as text
	else
		set txt_new to var's text items
	end if
	set AppleScript's text item delimiters to delims_old
	return txt_new
end itemize

on trim(someText)
	repeat until someText does not start with " "
		set someText to text 2 thru -1 of someText
	end repeat
	
	repeat until someText does not end with " "
		set someText to text 1 thru -2 of someText
	end repeat
	
	return someText
end trim
Create the script in ScriptEditor, and install it by placing it in ~/Library » Application Support » Quicksilver » Actions, then restarting Quicksilver. (Configuration instructions are in the top of the script.)

To use this script, when you have text in your first Quicksilver pane, select Clip to Evernote (or whatever you call this script if you change the name). The text format is as follows -- you must have a title or note (or both), but everything else is optional.
title:your note here nb:notebook tags:space-separated tags here
The only thing that matters is that any specified notebook or tags must come after title and note. Here are a few examples:
  1. this is a note with no title or anything -- creates note with your default title, notebook, tags (if specified), otherwise just goes straight into Evernote as is.
  2. todo:buy batteries -- creates note with title todo and note buy batteries.
  3. remember to buy batteries: tags:todo household -- creates note with title remember to buy batteries and tags todo and household.
  4. great idea for meeting: tell everyone to put 20% of salary in mattress nb:Work tags:meeting finance meltdown -- creates note tell everyone to put 20% of salary in mattress with title great idea for meeting in notebook Work with tags meeting, finance, and meltdown.
[robg adds: I haven't tested this one.]
    •    
  • Currently 3.13 / 5
  You rated: 1 / 5 (8 votes cast)
 
[30,093 views]  

Clip to Evernote via Quicksilver and AppleScript | 14 comments | Create New Account
Click here to return to the 'Clip to Evernote via Quicksilver and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clip to Evernote via Quicksilver and AppleScript
Authored by: jedverity on Oct 03, '08 07:27:48PM
Note: as of 10/3/08 at 10:00 EDT the script above is posted incorrectly. A proper version can be found here: Clip to Evernote

[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: robg on Oct 11, '08 06:34:42AM

The script should now be correct. Sorry for the errors.

-rob.



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: Rubin421 on Oct 20, '08 09:39:36AM

On my machine with the latest version of everything, both scripts have the same issue: if I don't specify a notebook to put the note into, nothing happens (i.e., the script doesn't create a note in the default notebook).



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: jedverity on Nov 01, '08 10:05:21AM

Sorry! Here is a replacement with that fixed.


--begin code

property defaults : {notebook:"", tags:"", title:""}
property special_delim : ";"

global txt, pspecial, cpos

using terms from application "Quicksilver"
on process text qtxt
my mainprogram(qtxt)
end process text
end using terms from

on initvars(qtxt)
copy qtxt to txt
set pspecial to 10000000
end initvars

on mainprogram(qtxt)
my initvars(qtxt)
set ztags to getdata("tags:", defaults's tags)
set znotebook to getdata("nb:", defaults's notebook)
set ztitle to gettitle()
if pspecial < txt's length then
set pend to (pspecial - 2)
else
set pend to txt's length
end if
set znote to getnote(pend)
set ztags to itemize(ztags, " ")
--return {ztitle, znote, znotebook, ztags}
my CreateEvernote(ztitle, znote, znotebook, ztags)
end mainprogram

to CreateEvernote(t, n, nb, tg)
if nb ≠ "" then
tell application "Evernote" to create note with text n title t notebook nb tags tg
else
tell application "Evernote" to create note with text n title t tags tg
end if
end CreateEvernote

to getdata(label, default)
set o to offset of label in txt
if o > 0 then
if o < pspecial then
set pspecial to o
end if
set chunk to my trim(itemize(txt, label)'s item 2 as string)
if label = "nb:" then
set nxt to "tags:"
else
set nxt to "nb:"
end if
set chunk to my trim(itemize(chunk, nxt)'s item 1 as string)
if (offset of special_delim in chunk) is not false then
return itemize(chunk, special_delim)'s item 1
else
return chunk
end if
else
return default
end if
end getdata

to getnote(meta_start_pos)
try
set start_pos to cpos + 1
on error
set start_pos to 1
end try
if start_pos > meta_start_pos then
return ""
else
return my trim(text start_pos thru meta_start_pos of txt)
end if
end getnote

to gettitle()
set title to my getdata("title:", defaults's title)
if title = "" then
set cpos to offset of ":" in txt
if cpos > 0 then
set title to my trim(text 1 thru (cpos - 1) of txt)
end if
end if
return title
end gettitle

to itemize(var, delim)
set delims_old to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
if var's class = list then
set txt_new to var as text
else
set txt_new to var's text items
end if
set AppleScript's text item delimiters to delims_old
return txt_new
end itemize

on trim(someText)
repeat until someText does not start with " "
set someText to text 2 thru -1 of someText
end repeat

repeat until someText does not end with " "
set someText to text 1 thru -2 of someText
end repeat

return someText
end trim

--end code



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: decavolt on Dec 17, '08 02:56:18PM

Rubin421 - If you set a default notebook in the Applescript, your clips will post to Evernote properly. Otherwise, you need to specify a notebook in the clip.

property defaults : {notebook:"NOTEBOOK NAME HERE", tags:"", title:"untitled"}



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: pattulus on Jan 25, '09 04:47:52PM

I'm yearning for a Launchbar version of this one. I tried to rewrite it, so that I could trigger the applescript via Launchbar, but had no success :[

anyone with brains around here who can rewrite this?



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: jwedwards74 on Jun 11, '09 07:10:17AM

Excellent Tip, thanks so much!



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: Landdogger on Jan 18, '10 09:09:35AM

This is really great, thanks for the all the work!

Is there a quick fix so that the text entered does not have to be case sensitive?



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: jedverity on Mar 17, '10 07:59:21PM

I'll post a fix for this soon...



[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: retractable on Feb 03, '10 06:54:36AM
Great! Thanks for posting this retractable lanyard

[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: jedverity on Mar 17, '10 07:58:46PM

I've updated the script to be a little easier to use and to be more (but not completely) compatible with Evernote's email tagging syntax.

Instead of nb:notebook, you type @notebook

Instead of tags:tag1 tag2, you type #tag1, tag2

If you use commas in your tags, you can change the "tag_delimiter" argument to whatever you want.

Note also that this means you can't have @ or # elsewhere in your note!

Get it here: http://jedverity.com/public/Clip%20to%20Evernote.zip



[ Reply to This | # ]
Fix The Parsing of The Note's Title in Clip to Evernote via Quicksilver and AppleScript
Authored by: bighbln on May 23, '10 02:49:51AM
Hi, the titles were not being parsed correctly due to a bug. Changing the "=" into "≠" as below will fix it.

to gettitle()
	set title to my getdata("title:", defaults's title)
	if title 
 "" then
		set cpos to offset of ":" in txt
		if cpos > 0 then
			set title to my trim(text 1 thru (cpos - 1) of txt)
		end if
	end if
	return title
end gettitle


[ Reply to This | # ]
Fix The Parsing of The Note's Title in Clip to Evernote via Quicksilver and AppleScript
Authored by: travellingman on Jun 18, '10 01:30:05PM
Actually, the problem I see is that the default title, if it is set to a non-empty string, overrides any title specified in the input string. This may be working-as-designed, but you may prefer it not to behave this way. If you want it the other way around...that is the input string's title, if present, overrides the default title... then try this for gettitle():
to gettitle()
	set title to ""
	set cpos to offset of ":" in txt
	if cpos > 0 then
		set title to my trim(text 1 thru (cpos - 1) of txt)
	end if
	if title = "" then
		set title to my getdata("title:", defaults's title)
	end if
	return title
end gettitle


[ Reply to This | # ]
Clip to Evernote via Quicksilver and AppleScript
Authored by: bighbln on May 23, '10 03:04:08AM

you adjust the script to allow this?

from the code this could be achieved by:
- using the first occurance of the # as the delimiter of the the tags, or
- to support the entering of tags with quotes like "tag1", 'tag2'

I am not familiar enough with applescript to make the changes my self.

thx



[ Reply to This | # ]