Sometimes I want to put a reference to several documents that are stored in my databases into another document. This script helps with that. I select several documents or groups, run the script, and it puts RTF link(s) to all of the selected documents onto the clipboard. The script works with documents or groups, and it works with contiguous or discontiguous selections - but for now it will not mix documents and groups in the same selection.
(*
Put rich text link(s) to the selected records (or groups) in DEVONthink onto the cliboard
For pasting to another document or rich-text aware location.
v1.20131106.korm
*)
tell application id "com.devon-technologies.thinkpro2"
try
set theSelection to selection
if theSelection is {} then error "Select an item, please"
set o_HTML to ""
repeat with thisItem in theSelection
set thisName to the name of thisItem
set thisURL to the reference URL of thisItem
set o_HTML to o_HTML & quoted form of ("<font face=\"helvetica\"><a href=\"" & thisURL & "\">" & thisName & "</a></font> </br>")
end repeat
set o_RTFLink to (do shell script "echo " & o_HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf" as rich text)
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
Here’s what happens: I have this selection in a database:
and I run the script, which puts this on the clipboard:
The underscored text are clickable links that, in an RTF-compatible document, will open the linked documents in DEVONthink
This script is very useful to me, thanks Korm I can now easily create a Rich Text index of what is in a Group, marvellous for my Genealogical work. Cheers.
Q.2) The label will always be green, which I have allocated to this type of document.
Q.3) I do not understand your blue – ‘K
Q.4) The name of the Group that the new RTF is located in, e.g. if I am creating a new RTF in a Group entitled "Allsop, Andrew” then “Allsop, Andrew” should be appended to the name of the RTF. The resultant name would then be "01 Contents Index Allsop, Andrew”.
Q.5) In the body of the RTF which, as it is a new one, will be blank.
I do not use KM or Text Expander, have LaunchBar which I like. Had a look at KM but the cost seemed prohibitive for what I would use it but might be wrong in that!!! Hope this is clear. Thanks for looking at it.