Change texture filename in a simple way

Hi,
I have a complex model with a lot of objects and a lot of materials.
Now, unfortunately I have to change some texture filenames to avoid conflict with other models.

Let’s simplify by saying that materials A, B, C, D, E, … Z are based on texture Name1.png

The only way I know is to rename Name1.png to NewName.png, and then to modify each single material A, B, C, … Z by replacing Name1.png with NewName.png.

This is ok but it’s a loooong job.

Is there any smart way to do this?

Thx!

python?

#pseudo code
for mat in bpy.data.materials:
    if mat has 'name1.png':
        mat.image='newname.png'

note that you didn’t specify which material type (BI, BGE, Cycles, etc), so this script is just to give a picture.