Is a script like this possible?

You mean something like this Script: Assign selected tag to matching records based on content and name?