change all materials to shadless?

i need to change all materials in my scene to shadless, before i go through all them manually, and there are alot, is there any way a python script could change a material setting for all materials in a file?

any help appriciated.

you know, you can set all materials to a single material when doing pre-vis rendering, to check the lighting. Use the Mat: text field in the RenderLayer panel.
And, the Game Engine ignores light, effectively making them shadeless automatically.

NOt so sure about that one…

The method you are going to need while iterating the materials is http://www.blender.org/documentation/244PythonDoc/Material.Material-class.html#setMode .

The following should do the trick:

import Blender
mats = Blender.Material.Get()
for i in mats:
    mode = i.getMode()
    if not mode & Blender.Material.Modes['SHADELESS']:
        mode+=4
        i.setMode(mode)
Blender.Window.RedrawAll()