comments only smart group script not working

I’ve been trying to use smart groups with a modified script (given to me by Eiron a while back) that looks only to the comments field for its parameters. I am using a key word in the comments field for files I want to group within the smart group. For some reason, it will work when I first create the folder—the tagged files show up in the new smart folder—but it won’t work for any subsequent files in which I use the exact same key words in the comment field. I used to be able to close and open the folder to get them to show up, but that’s not working.

Here is the script I’m using:

try
tell application “DEVONthink Pro”
repeat
display dialog “Enter the words to use:” default answer “” buttons {“Cancel”, “OK”} default button 2
set theWords to the text returned of the result
if theWords is not “” then exit repeat
end repeat
set theRecord to create record with {name:theWords, type:group, attached script:"~/Library/Application Support/DEVONthink Pro/Smart Group/Comments only.scpt"}
my triggered(theRecord)
end tell
on error error_message number error_number
if the error_number is not -128 then
display dialog error_message buttons {“OK”} default button 1
end if
end try
end run

on triggered(theRecord)
try
tell application “DEVONthink Pro”
if type of theRecord is group then
set theString to (name of theRecord) as string
search theString comparison no case within comments operator all words replicate to theRecord with removing replicants
end if
end tell
on error error_message number error_number
if the error_number is not -128 then
display dialog error_message buttons {“OK”} default button 1
end if
end try
end triggered

Any suggestions would be appreciated!

Alex,

please check if the path (~/Library/Application Support/DEVONthink Pro/Smart Group/Comments only.scpt) is correct and that the script is attached to the group (see Info panel).

It all looked correct to me, thus my puzzlement. But given what you said I tried renaming the script, also changing the name in the appropriate place within the script, and it works now. Very strange, since I had changed nothing since the last time I successfully used it (save for updating the program) and it all looked to be quite fine. I’m still perplexed, but it is now working.

Many thanks.