If the objects are not grouped or components, selecting all and then using the bucket or dragging a material from the material window works. Of course it works for groups too where no color has been applied to the faces inside the group, but that's not usually good texturing practice, may be OK for you.
Thru paint plugin is pretty much like painting. just hold down the mouse button and run over the objects: depending on your settings it will paint faces INSIDE groups and components as you go. It's a very good and deep plugin. Almost as fast as selecting it all and applying a color.
Now as you say "automate", maybe this is a code development question.