TemplateName is a property of the NotesDatabase object class.
All you need to do is write a little agent that opens the current db, and sets the value.
Of course, if you need to do that across hundreds of dbs, it is probably because you're not sure which template they are pointing to. So you'll more than likely need your agent to open all the dbs of the server and make the change sequentially. Which means iterating through the Notes directory.
If you need help on this, I can give you code that will quickly get you working.
Pascal.