I'm sharing a script that I wrote to help deal with the large number of materials and meshes I have in my architectural scenes. I used to spend a lot of time connecting pins to each other for every new mesh in my scene, and it was tedious especially with so many lines covering the scene graph. This script runs through all the material input pins of the selected meshes, and matches them to material output pins that reside inside a separate node graph where I have all my materials. Here's how it's used:
Inside your materials node graph, the output pins should be named to match the material names that come in with your mesh. (I work in Sketchup and bring in OBJ files) Select at least one mesh, and ONE node graph with the materials. Run the script (shortcut is ALT-L) and all names that match will be linked up. One more thing to note, there is a variable at the top of the lua file that goes:
local copy_materials = false
change this to
local copy_materials = true
and the script will COPY the materials rather than linking them. This will NOT copy any material input nodes, like diffuse textures, that are expanded out of the material. To get them to copy over, you have to collapse these other nodes into the material node. Roeland's script Move Nodes into Node Pins can help with this:
viewtopic.php?f=73&t=54108