Getting Hyperlinks as text from RTF records

My usual DT workflow goes like this: browsing sites with DT, selecting interesting texts and letting DT make a memo of this selection.
This selection is kept as RTF or RTFD record within the database.

Because I am mainly interested in the pure text, I use the “make text” function to convert the RTF document in a text document. That saves some KB a day and many MB over the weeks of working.

The disadvantage of this solution is that I am loosing the hyperlinks which are embedded in the RTF document.

So I would love to have a script which just collects all hyperlinks of a RTF document and writes it to the end of the document.

Looking to the Applescript dictionary I found out that “get links of” does work only with HTML documents.

But since an URL in RTF is coded in a special way it’s maybe possible to find all appearances of links and write them out.

The code in RTF reads like that:

{\field{\*\fldinst{HYPERLINK "http://www.devon-technologies.com"}}{\fldrslt 
\f0 \cf3 Devon Technologies}}'s

Does anyone have an idea how to approach that?

If it was a text file and I could use GREP I think I would be able to find a solution, but being in DT I have no idea.

Thanky for any hints,
macvet

Here’s a simple script adding the links of the frontmost rich text to the end of the document:


-- Append URLs of rich text

tell application "DEVONthink Pro"
	set theURLs to ""
	tell text of think window 1
		repeat with theAttribute in attribute runs
			set theProperties to properties of theAttribute
			if exists URL of theProperties then
				set theURL to (URL of theProperties) as string
				if theURL does not start with "DEVONwiki" then
					set theURLs to theURLs & theURL & return
				end if
			end if
		end repeat
		make new paragraph with data (return & theURLs) at end
	end tell
end tell

:slight_smile: