Search or List backlinks to a record's URL

Hi,

I’m new to DEVONthink and I’m thinking of buying it.

I save loads of online articles/web pages and was wandering if there’s a way to search for/list all records that have links to this item’s URL. Sort of backlinks to external resources.

Often the title is not enough to find mentions of a record, because the anchor text is different from the record’s title.

I know there’s a hidden preference to index the source markdown contentes which would give me what I want.

But there are a lot of trade-offs using markdown to clip contents. My main concern is fidelity and the better comments and annotation tools using PDFs (summarize highlights, highlighting in mobile without having to go to edit mode, etc)

I’d be open to try to script something if given some clues as to how I could go about that.

So I was wandering if there’s a way to index the URL of links in other file formates (preferably PDFs, by also HTML (for web archives, formated notes and pure HTML files))

EDIT:

It occurs to me that all records list their respective forward links, and so I presume this information is indexed, and so this should be feasible.

Any way to search this list via the UI?

How could I handle/work with this list via scripts?

You might want to have a look at the Document > Links inspector which lists incoming item and Wiki links. It’s also possible via AppleScript, see incoming reference and incoming Wiki reference. And to find items having incoming item links, this is possible via the advanced search or md_incomingItemLinkCount>0

Thanks, but I was referring to external URL links that link to an URL that corresponds to an internal record’s URL property value. IE to see which clipped articles link to another record’s URL property value, without my having to first create an item link OR a wikilink between the two articles.

Say I clip a web article. Let’s call it Record A. This article’s content links to url: https://siteB.com/ArticleB.html

Say I clipped article B some three months ago. Lets call it Record B. Record B has URL property: https://siteB.com/ArticleB.html. Obviously there’s no item link and no wikilinks between those two articles, as they were created months apart.

If I open Record A in the inspector I can see its external links, ie that it links to the URL https://siteB.com/ArticleB.html. And Record B has the same URL in its URL property. So DEVONthink has all the information it needs to know that these items are linked, and to perhaps show backlinks, even though I haven’t done anything and possibly do not know this.

Is there a way to query a record’s forward external URL links, so that I may perhaps search or create scripts that show me all records that link to Record B URL property value? This would return me Record A and any other record that also links to the URL that Record B has as its URL property value.

`

Looking at the dictionary it says:

Incoming reference n [inh. record > item] : A reference from another record.

incoming Wiki reference n [inh. record > item] : An automatic Wiki reference from another record. This depends on the current Wiki linking preferences.

So my understanding is that the first both items refer to manual internal links IE links I manually create to an internal record and not links that were made an external URL.

References = DEVONthink item links.
Wiki references = WikiLinks generated within DEVONthink. (See Preferences > WikiLinks.)

Yep that’s what I thought.

No way to query outgoing URL links for a record though? Via Search, SmartRules OR AppleScript?

Search and smart rules? No…
Vanilla AppleScript? No.
AppleScript Objective-C? Possibly but beyond most laypeople to code.

I do have an option but I want to discuss it with development first.

Here’s an approach, though we don’t usually suggest shell commands…

tell application id "DNtp"
	if (selected records) is {} then return
	repeat with theRecord in ((selected records) whose (type is PDF document))
		set linkList to (do shell script "grep -aiE 'http[s]*' " & quoted form of (path of theRecord as string) & " | sort -fu | tr -d '()'")
		
		if linkList is not "" then
			-- Do things with the text returned, if present. 
			-- In this case, I just create a plain text file of the links.
			set linkDoc to (create record with {name:((name of theRecord) & " links"), type:text, content:linkList} in incoming group)
		end if
	end repeat
end tell

Perhaps adding “://” to the https? grep would make the search more specific?

Yes, that’s certainly doable.

Wouldn’t the same be possible without using grep by searching the record‘s plaintext property? Or perhaps I’m misunderstanding the purpose of the script.

The URL isn’t necessarily in the plain text of a PDF, a PDF of this forum thread for example.

In a PDF from another thread, these URLs are surfaced…

Bear in mind, I’m not saying it’s the solution, just an potential option.