I have this script, but its not working as expected
import bpy
for img in bpy.data.images:
print("%s" % img.name)
if( ".0" in img.name):
img.name=img.name[:-4]
print("%s" % img.name)
I want to have one texture on different materials, now i have something like this
Edit: Solved.
for mat in bpy.data.materials:
if mat.node_tree:
for n in mat.node_tree.nodes:
if n.type == 'TEX_IMAGE':
if n.image is none:
print(mat.name,'has an image node with no image')
elif n.image.name[-3:].isdigit():
n.image = bpy.data.images[n.image.name[:-4]]
for imgs in bpy.data.images:
if imgs.name[-3:].isdigit():
print(imgs.name)
imgs.user_clear()