From a material's name, automatically "fill it in", and have it point to a same-named image texture I am attempting to make it so that I can do the following:


Import meshes. These add a large number of materials. already contain the (empty materials).
Add all of the image texture files.
Make all of the previous materials refer to the image texture files based on the materials' filenames. (I.E. if the material said brickfloor001, it would build a material that has one image texture named brickfloor001)


However, I have been unable to do the third step, automating the node setup and adding in the images automatically. What is a method / addon for doing this?

I've already checked Node Wrangler's texture setup. This still forces you to go material-by-material.

(I want to avoid manually creating the materials, because this is nearly a hundred different ones.)
Under the assumption, that you have one 'Image Texture' node in your material setup and all the image filenames are unique, it should be something like :

for material in bpy.data.materials:  
    #loops through all the materials
    mname = material.name            
    #get the name of the material
    img_fname = "{}.png".format(mname) 
    #get mname.png
    img_full_path = "path/to/image/files/{}".format(img_fname) 
    #get path to image, including the image
    bpy.data.images.load(img_full_path, check_existing=True) 
    #load the image to the internal database
    material.node_tree.nodes['Image Texture'].image =bpy.data.images[img_fname] 
    #assign image by filename to material image texture input


You need to work out the path to the image files. Best to open the python console and try to load one image manually, using the

bpy.data.images.load()


command, then insert the base path that worked. 

Edit: img_fname was in quotation marks in bpy.data.images. That would not have worked.