Splitting results from multiple DA searches for DEVONThink

Hi there,

I want to run multiple scheduled DevonAgent searches. It would be good to drop the results into a different folder or inbox in DevonTHINK for each search query for processing.

Can this be done?

Cheers,

Patrick

This is not yet possible but we’ll consider this for future releases. In the meantime the only possibility are customized scripts. E.g the following script automatically creates new groups for different search sets & queries:


on results(theResults, theSet, theQuery)
	tell application "DEVONagent"
		try
			set pathToAdditions to ((path to application id "com.devon-technologies.agent" as string) & "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
			
			tell application "DEVONthink Pro" to set theGroup to create location "/" & theTitle
			
			repeat with this_result in theResults
				set this_URL to |URL| of this_result
				set this_HTMLURL to helperLibrary's convertText2XML(this_URL)
				set this_title to |Title| of this_result
				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>"
				
				tell application "DEVONthink Pro"
					if not (exists record with URL this_URL) then create record with {name:this_title, type:html, source:this_HTML, URL:this_URL} in theGroup
				end tell
			end repeat
		end try
	end tell
end results

Note: The script has to be copied to the folder ~/Library/Application Support/DEVONthink Pro 2/Action Scripts.