Script to act on every record in a smart group

Feel silly asking this but I’ve searched and searched and haven’t figured it out.

I’m trying to construct an Applescript that may be attached to a smart group and will act on every item listed by that smart group when the smart group is selected. Any guidance would be appreciated.

You’d want a script with this general structure

on triggered(theRecord)
		tell application id "DNtp"
			if type of theRecord is smart group then
				set theChildren to children of theRecord
				-- do something with the children
			end if
		end tell
	end try
end triggered

Attach the compiled script to the smart group using the “Script” element in Show Info for that group.

FWIW, I’ve used smart group attached scripts and they get really annoying after a while because smart groups are saved searches, the content might always be in flux, and even editing the predicates for a smart group can trigger the script unless you un-assigned the script in Show Info before editing the predicates. YMMV :confused: