Even if the search results have 25 records, the FILE IN DT script usually captures about 3 or 4 of them. At first I thought it was grabbing only the “best matches” as indicated by the color bar, but that’s not the case. It seems random. I don’t see any “filtering” in the script. If I use the checkbox for send results to DT, it sends every result.
I did a broader search and got 179 results. None were previously added to the database. When the script ran, it added just 5 of the results to DT.
Could you please post the script and the search set? Otherwise it’s impossible to tell whether that is correct or just a wrong setting or a buggy script.
-- Created by Christian Grunenberg on Mon Jan 14 2013.
-- Copyright (c) 2013-2017. All rights reserved.
property pFormat : "WebArchive" -- Either HTML, Bookmark, Summary, WebArchive or PDF
property pReadability : true -- Apply readability to WebArchive and PDF. Requires DEVONthink 3.
on results(theResults, theSet, theQuery)
tell application "DEVONagent"
try
tell application id "DNtp"
set theGroup to missing value
set theDatabase to the current database
end tell
set pathToApp to (path to application id "com.devon-technologies.agent" as string)
set pathToIcon to POSIX path of (pathToApp & "Contents:Resources:DEVONagent Pro.icns")
set pathToAdditions to (pathToApp & "Contents:Resources:Script Additions.scpt") as alias
set helperLibrary to load script pathToAdditions
--if theSet is not equal to theQuery then
-- set theTitle to theSet & ": \"" & theQuery & "\""
--else
set theTitle to theSet
--end if
repeat with this_result in theResults
set this_URL to |URL| of this_result
set this_title to |Title| of this_result
set full_date to |pubDate| of this_result
set this_date to (characters 6 thru 16 of full_date)
if pFormat is "Summary" then
set this_HTMLURL to helperLibrary's convertText2XML(this_URL)
set this_HTML to "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><title>" & helperLibrary's convertText2XML(theTitle) & "</title></head><body><small>"
set this_HTML to this_HTML & "<div><h3>" & helperLibrary's convertText2XML(this_title) & "</h3></div>" & "<div>" & helperLibrary's convertText2XML(|Text| of this_result) & "</div>" & "<div><a href=\"" & this_HTMLURL & "\">" & this_HTMLURL & "</a></div>"
set this_HTML to this_HTML & "</small></body></html>"
else if pFormat is "HTML" then
set this_HTML to |source| of this_result
else
set this_HTML to ""
end if
tell application id "DNtp"
if not (exists record with URL this_URL in theDatabase) then
if theGroup is missing value then
set theAgentGroup to create location "/DEVONagent" in theDatabase
try
set exclude from tagging of theAgentGroup to true
set thumbnail of theAgentGroup to pathToIcon
end try
set theGroup to create location "/DEVONagent/" & theTitle in theDatabase
end if
if this_HTML is not "" then
create record with {name:this_title & " (" & this_date & ")", type:html, source:this_HTML, URL:this_URL} in theGroup
else if pFormat is "WebArchive" then
create PDF document from this_URL name this_title & " (" & this_date & ")" readability pReadability in theGroup
else if pFormat is "PDF" then
create PDF document from this_URL name this_title & " (" & this_date & ")" readability pReadability in theGroup
else
create record with {name:this_title & " (" & this_date & ")", type:bookmark, URL:this_URL} in theGroup
end if
end if
end tell
end repeat
end try
end tell
end results```
the behavior is the same on all search sets - I have tried quite a few different ones.
This might fail in case of a result without a date and then the script will stop. Add a try... on error ... end try
block to handle this, e.g.
try
set full_date to |pubDate| of this_result
set this_date to (characters 6 thru 16 of full_date)
on error
set this_date to "-"
end
Thank you, that seems to have been the issue. My first line of code too, lol.