Here’s a triggered script to implement a smart group for contents modified during the last week:
-- Smart Group for Last Week
-- Created by Christian Grunenberg on Mar Fri 10 2006.
-- Copyright (c) 2006. All rights reserved.
property pDays : 7
on run
tell application "DEVONthink Pro"
try
set theRecord to create record with {name:"Last Week", type:group, attached script:"~/Library/Application Support/DEVONthink Pro/Smart Group/Last Week.scpt"}
my triggered(theRecord)
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
end tell
end run
on triggered(theRecord)
try
tell application "DEVONthink Pro"
if type of theRecord is group then
set theChilds to children of theRecord
repeat with thisChild in theChilds
if number of replicants of thisChild > 0 then delete record thisChild in theRecord
end repeat
set theDate to (current date) - 3600 * 24 * pDays
set theResults to contents of current database whose modification date is greater than theDate
repeat with thisResult in theResults
replicate record thisResult to theRecord
end repeat
end if
end tell
end try
end triggered
Just save the script in the folder ~/Library/Application Support/DEVONthink Pro/Smart Group as “Last Week.scpt”. Then run it via the Scripts menu to create the smart group, afterwards the group will be automatically updated.
Warning: If your database contains more than 3000-4000 contents, this script might be too slow.