Copy item link with name from spotlight comment


I’m trying to make an applescript that copies the link of an item and gives the pasted hyperlink a name that is described in the item’s spotlight comment. Copying parts from the Annotation script I have managed to create such a link at the end of the active document (make new word with data (theComment) with properties {URL:theQuotationUrl} at the end of text of think window 1).

I’m wondering if it possible to take the output from the “make” command and put it on the clipboard? Or is there any other command that does what I want? I have also tried putting the link in HTML as string on the clipboard but this just pastes the HTML and not a hyperlink.

tell application id "com.devon-technologies.thinkpro2"
		set theFrontmostDocument to content record
		if (theFrontmostDocument is missing value) then error my helperLibrary's 		localizedString("No document shown. Please select a document, then try again.")
		set theComment to comment of theFrontmostDocument
set theDocumentUUID to uuid of theFrontmostDocument
		set theQuotationUrl to ("x-devonthink-item://" & theDocumentUUID) as string
		make new word with data (theComment) with properties {URL:theQuotationUrl} at the end of text of think window 1
end tell
Puts an RTF-formated link to the DEVONthink current record on the clipboard.
The text of the link can be one of:
- the Spotlight Comment of the current record, or
- the name of the current record

No error checking.


tell application id "com.devon-technologies.thinkpro2"
	set v_URL to (the reference URL of (the first item of (selection as list)) as string)
	-- un-Comment the command below that will control the text of the link
	set v_Text to (the comment of the content record of think window 1) -- Spotlight comment as link text
	-- set v_Text to (the name of the content record of think window 1) -- Name of record as link text
	set v_HTML to quoted form of ("<font face=\"helvetica\"><a href=\"" & v_URL & "\">" & v_Text & "</a></font>")
	do shell script "echo " & v_HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
end tell

Nice. Thank you, korm.

For those who use Markdown, this version puts on the clipboard a Markdown link to the current document. Uses “name” as the link text. Change

name of the item


comment of the item

if desired

tell application id "com.devon-technologies.thinkpro2"
	set theItem to (the first item of (the selection as list))
	set the clipboard to "[" & name of theItem & "](" & reference URL of theItem & ")"
end tell

I am trying to figure out a way to copy and paste a hyperlink to a DT item into Word so that the title of the item appears in the hyperlinked text in Word.

There is an Apple Script for this in this thread written by Korm, but I’m not familiar with Apple Script so getting it to work has been a challenge. There seems to be some text in the script that you are supposed to remove before executing it. Could someone help me figure out the exact script to put in my Script Editor?