Check if item is in DevonThink

@korm

Hi again Korm, is there away to modify your script to check if URL is already in the “Reading list” ? Currently this script doesn’t check in the Reading list.

Thank you.

tell application id "com.apple.Safari" to tell window 1 to set theURL to current tab's URL

tell application id "DNtp"
	try
		set theDatabases to databases
		set theResults to {}
		repeat with thisDatabase in theDatabases
			set thisDatabasesResults to lookup records with URL theURL in thisDatabase
			set theResults to theResults & thisDatabasesResults
		end repeat
		
		set ResultCount to (count of theResults)
		
		if ResultCount = 0 then
			display notification "No item found" with title "DEVONthink"
			return
		end if
		
		if ResultCount = 1 then
			open window for record (item 1 of theResults)
			activate
			return
		end if
		
		if ResultCount > 1 then
			set theSearchURL to "x-devonthink://search?query=" & theURL
			open location theSearchURL
		end if
		
	end try
end tell

Here’s a small example:

tell application "Safari" to tell window 1 to set theURL to current tab's URL

tell application id "DNtp"
	try
		set theReadinglist to reading list
		repeat with theItem in theReadinglist
			if theURL is equal to (|url| of theItem) then
				display dialog "In reading list"
				exit repeat
			end if
		end repeat
	end try
end tell

Thanks Chris, this works.

I wonder if the script can be merge into one. Look in “databases and Reading List” Right now these are two separate scripts.

The scripts could be merged but it’s not possible to open reading list items or to find them via the search like in the first script.

ok, perhaps in the future.

Thank you.