Update all materials, but keep their color and textures I am working with a very large scene file that was imported as .obj. This gave me basic blender internal materials with colors and textures. I then used an addon to convert all of the BI materials to Cycles ones (https://blenderartists.org/forum/showthread.php?394600-Materials-Specials-amp-conversion)

What I have now is every material is a Diffuse Node with a color, or with an image texture node hooked up to it with the appropriate texture.

What I would like to do now is make a more complex node setup (likely in a group), and then copy it to all the objects in the file, but have them keep their own diffuse color and texture.

Are there any existing addons or scripts that can do this?
import bpy
for material in bpy.data.materials:
    if (material.use_nodes):
        nodes = material.node_tree.nodes
        links = material.node_tree.links
        for node in nodes:
            if (node.name=='Material Output'):                            
                out = node
            elif  (node.name=='Image Texture'):
                img = node
            elif: (node.name=='Diffuse BSDF'):
                diff = node
                # if diffuse node is not linked,then save it's colorvalue
                if not(node.inputs[0].is_linked):
                    color = node.inputs[0].default_value
                else:
                # else we should set color to None, and be aware
                    color = None
            else:
                nodes.remove(node)

        hold = nodes.new('ShaderNodeHoldout')
        geo = nodes.new('ShaderNodeNewGeometry')
        mix = nodes.new('ShaderNodeMixShader')
        RGB = nodes.new('ShaderNodeRGB')
        if (color==None):
            if (img==None):
                #No image and diffuse was not empty, set color to grey
                RGB.outputs[0].default_value = (0.7,0.7,0.7)
                img = RGB
        else:    
            RGB.outputs[0].default_value = color
            img = RGB

        links.new(out.inputs[0],mix.outputs[0])
        links.new(mix.inputs[0],geo.outputs[6])
        links.new(mix.inputs[1],diff.outputs[0])
        links.new(mix.inputs[2],hold.outputs[0])
        links.new(diff.inputs[0],img.outputs[0])


This code does almost what you want.
It saves one image texture node, one material output node, and deletes everything else, and then adds emission and holdout node and connects them via backfacing. As for part of your own shader, i think you can save it as a node group and append it into node setup via python too