Append and replace materials

Is it possible to append all the materials from one .blend file to another and have Blender to automatically replace all the materials that share the same names? When appending Blender always rename the materials datablocks like material.001 when they have the same names.

The case is:
I work together with an architect who models in Sketchup. I use the BlendUp addon for exporting, it is great because it exports directly in .blend format. Then, in Blender, I add lamps, cameras and I edit materials. So… if we later update the model I can reuse all my lamps and cameras just by appending them to the new exported blend, but I loose all the material I worked on. I haven’t found a way to keep this work without having to do a manual replacement of all the materials one by one. (Materials Utils addon does material replacement but as I said, one by one)

I haven’t come up with a more automatic solution to this problem so I was wondering if it could be made in python. I’m not coder (so pseudocode from now) but I guess that it should be possible if I could make a “for” loop like:

for matTarget in bpy.data.materials:if matTarget.name == matSource.name:
[INDENT=2]replace material[/INDENT]

But I don’t know how to replace a material and I don’t know how to access data in another blend file… any thoughts?

If someone come up with a known way to deal with this problem, please let me know. It would be appreciated! :slight_smile: