How to group Smart Groups / Rule for DTTG based on tags?

Here’s a sample of the script I use to process files in my inbox

tell application id "DNtp"
	
	set selectedNotes to (get selection)
	
	repeat with theNote in selectedNotes
		
		--
		--   Code to identify the variables
		-- 
		set theFilingGroup to get record at "/General-Filing" in database "FilingCabinet"
		
		set theNote to move record theNote to theFilingGroup
		set name of theNote to theTitle
		set tags of theNote to tags of theNote & theTagList
		if setDueDate then add custom meta data theDueDate for "taskduedate" to theNote
		set label of theNote to taskLabel
		set locking of theNote to true
		
	end repeat
end tell
2 Likes