Best way to check all open databases for records with a given URL

What is the most efficient way to check all open databases for records with a given URL

I’m doing a

repeat with thisDatabase in every  database

loop. Is this the best way to do it?

That would be a common and useful type of iteration.

Thanks. I was just wondering…

Another option is to use search command? It’s much faster than repeat loop unless @BLUEFROG has other options…

tell application id "DNtp"
	
	set theURL to display name editor "URL" default answer ""
	set theResults to search "url:" & theURL
	-- do whatever u need to do with theResults
end tell

The URL should at least be quoted to avoid any conflicts with the search syntax.

Like this? BTW I tested the two lines and it seems working but u are right to be safe…

set theResults to search "url: \"" & theURL & "\""
1 Like

Exactly.

Very interetsing! So is this referred over database looping over lookup records in db?

I think it’s just another great update of the older search command in the dictionary that incorporates the identical function of the search field (of the viewer window) into AppleScript . The search string can/is identical with the search string to be used in viewer window and will return the identical results. I’ve no idea on its relationship with lookup records but it is FAST and much more flexible that lookup records commands.

Through experimentation I found that there is a big difference between lookup URL and search URL:

  • search finds documents where the URL contains the given URL string while
  • lookup finds only documents where the URL is exactly the given string

u can use “url==” for exact match, the syntax is exactly the same as those in the search field.

Cool! That does the trick! Thanks heaps!

BTW, found it now in the documentation, too. (Had a bit of trouble with Clearview, my ePUB reader on the Mac: It won’t search for “==”…)

A 2nd BTW: If using == quoting the URL doesn’t seem to work, so the search needs to be unquoted:

set theResults to search "url==" & theURL