I have a defined DA search set to gather news pages that meet certain criteria. I’d like to run that search daily and add the new reults into a specified DTP group, either a standard “news” group or, even better, a newly created group with that day’s date.
I’m a new mac user so automator and applescript are both new to me. Happy to learn though, if someone could give me a couple of pointers.
Looking at automator (as being easier !) there doesn’t seem to be a way to run a DA search using an automator action. Is that right?
OK, after digging into applescript this weekend, this is what I’ve got. It nearly works, but seems to stop when it tries to get the source of the first DA result. Running the script with just the name and url of the search result works fine.
(* Create a new group with the current date in yyyymmdd format*)
tell application "DEVONthink Pro"
set theGroupName to create location "/path/to/new/group/" & (((year of the (current date)) as number) * 10000) + (((month of the (current date)) as number) * 100) + ((day of the (current date)) as number) as string
end tell
tell application "DEVONagent"
try
search "[search string]" using set "[search set]"
set theSearch to search window 1
(* Wait until the search has finished. *)
repeat until searching of theSearch is false
delay 5
end repeat
set theResults to search results of theSearch
repeat with theResult in theResults
set record_name to title of theResult
set record_url to URL of theResult
set record_source to source of theResult
tell application "DEVONthink Pro" to create record with {type:html, name:record_name, URL:record_url, source:record_source} in theGroupName
end repeat
end try
end tell