Posting tags (or folders) to delicious

Hello all,

thank you for providing such a great venue for all kinds of scripts and thanks to the authors for providing such a great program. I have now been customizing DT for two weeks, but could not make the following work:

I would very much like to post items via my DT to delicious, preferably via an internal DT window. I could not get this work, and have it now via my browser via the following code (modified from another script - thanks!!)

-- NetNewsWire to
-- Grabs info from current browser window in NetNewsWire
-- and posts it to your account
-- Change YOUR_ACCT_NAME below to your own info
-- Based on work by "JCHRIS":
-- Modified by Daniel Jalkut to base source URL on selected tab, so it will 
-- work for both subscriptions and web URLs. Latest version available here:
-- Red Sweater Version 1.0

set theAccountName to "xxx"

tell application id "com.devon-technologies.thinkpro2" to set thisSelection to the selection
if thisSelection is {} then error localized string "Please select a document or group, the try again."
if (length of thisSelection) > 1 then error localized string "Please select only one document or group, then try again."
tell application id "com.devon-technologies.thinkpro2"
	set thisItem to first item of thisSelection
	set theTitle to (name of thisItem) as string
	set theURL to (URL of thisItem) as string
end tell

if (theURL is not equal to "") then
	set deliciousURL to "" & theAccountName & "?v=2&url=" & theURL & "&title=" & theTitle & "&tags=" & theUUID
	tell application "System Events"
		open location deliciousURL	
end if

I would like to fetch the tags (i.e. the file location maps displayed as tags like “Politics” “International Relations” “Afghanistan” “Uruzgan”) to delicious tags and secondly have the window displayed inside DT as opposed to in a browser window.

Thank you so much for any help you can offer. It is highly appreciated!

Very warm regards,


Here’s a script that should work, although the tags aren’t transmitted for some unknown reason:

-- Post to

property pAccountName : "" -- Set your account name here

tell application id "com.devon-technologies.thinkpro2"
		set thisSelection to the selection
		if thisSelection is {} then error localized string "No selection."
		set theWindow to think window 1
		repeat with thisItem in thisSelection
			set theURL to URL of thisItem
			if theURL is not missing value and theURL is not "" then
				set theTitle to name of thisItem
				set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " "} -- Tags separated by spaces
				set theTags to (tags of thisItem) as string
				set AppleScript's text item delimiters to od
				set theURL to do JavaScript "encodeURIComponent('" & theURL & "')" in theWindow
				set theTitle to do JavaScript "encodeURIComponent('" & theTitle & "')" in theWindow
				set theTags to do JavaScript "encodeURIComponent('" & theTags & "')" in theWindow
				set deliciousURL to "" & pAccountName & "?v=2&url=" & theURL & "&title=" & theTitle & "&tags=" & theTags
				open tab for URL deliciousURL in theWindow
			end if
		end repeat
	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

Hi Christian,

Congratulations on “going final”!

I wondering if this might be a bug relating to how DT internally exposes the tags to AppleScript…

For what it’s worth, a user of my DEVONthink-to-Evernote AppleScript posted a comment this morning that the script wasn’t working now. When I stepped through the script with my editor, the script halted every time I called the tags of a DEVONthink item.

The tag variable was showing as «empty», so I thought maybe I could do a missing value check to insert a default tag in the transfer for untagged items. No luck – the script halts whenever it hits an untagged item.

Am I missing some (probably obvious) way to deal with this?

No, it’s not related to AppleScript. I’ve also entered some URLs on my own in a browser window but without luck, the tags aren’t accepted by

Just send me the script plus some sample data and I’ll check this.


Here is a link to the source code of the script (and a compiled copy for download):

The sample data will obviously be from your own DEVONthink Pro database, but let me tell you what I noticed as I was working with my own data and also stepping through the script line-by-line with Script Debugger:

  • DEVONthink Pro notes with tags exported correctly to Evernote, and Script Debugger was able to read the values for the tags (e.g., everything works as expected);

  • DEVONthink Pro notes without tags caused the error and, when I stepped through the script line-by-line with Script Debugger, that’s when I saw that 1.) The script halted directly after trying to retrieve the (non-existant) tags, and 2.) the debugger showed the tag variable was «empty» ;

Let me know if you have any questions – and thanks for trying to get to the bottom of this!

Instead of …

				if the (the tags of this_item) is not missing value then
					set theTags to (the tags of this_item)
					set theTags to defaultTag
				end if

…use this:

				if exists tags of this_item then
					set theTags to (the tags of this_item)
					set theTags to defaultTag
				end if

The next release will fix this and the tags property will return an empty list/array instead of missing/undefined values in case of no tags.

Thanks Christian – this works great!

Your code has been incorporated into a new revision of the script and posted.

Thanks for this. Works fine for me except the tagging as you mentioned. Have you or anyone else found a solution to this so that the tags are added?

Really nice to have the ability to send out a URL in DTP to Delicious. Very handy so thanks for providing this script.