bpy remove duplicate images (.001 .002 .003 etc.)
img.name=img.name[:-4] is renaming the image to match the original image name, as this name already exists a numeric suffix is added to the other image with that name, which just undoes the change.
You need to go through your material nodes and get each image node to use the same image.
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]]

Note that the last line doesn't just change the name used, it changes the image data block that the image node is linked to.
Once you have removed the users of the duplicate images they will be removed after you save and re-open the file.