How to change Image texture node attribute based on image name

                         Hi Guys,

I have a complex project, containing a lot of materials an image textures.

I would like to change for particular image its color / non-color setting fast,
without looking for a needle in a haystack and manually traversing all the
materials

for example:

I have an “texture_bump.jpg” which is used in several shaders, but I want
to change color to non-color in all Image texture nodes in all materials where
“texture_bump.jpg” is used

so a short script which finds the image texture node by name of an input image,
and changes its attribute to non-color or color

many thanks for any help or where to start

Jozef

I came up with this small snippet,

import bpy

count = 0

mats = bpy.data.materials

for mat in mats:
    if mat.use_nodes == True:
        nodes = mat.node_tree.nodes

        for node in nodes:
            if node.bl_idname == 'ShaderNodeTexImage':
                if node.image == bpy.data.images['myTexture.jpg']:          # change the name of the texture here

                    node.color_space = 'NONE'                
                    #node.color_space = 'COLOR'
                    
                    count = count + 1

print("Total changes made:", count)

please leave me a reply, if you find it useful in your project :wink:

many thanks,

Jozef