Create layers from material


I was wondering if there is a script out there that'll create layers from assigned materials, match the material name to the layer name and place all objects with a given material on the associated layer ?

And if it could batch process a string of .Max files that would be awesome :)

I need to export a bunch of Max objects as Revit content and Revit will only assign materials for imported objects by layer.

If anyone can help me out with this I would appreciate it very much.