Upgrading an Old Python Script : Change all Image Paths at once I found those script i Think it was for Blender 2.49 to change all imagePath at once,
but I cant get it to work in Blender 2.8...
Can some one help , it would be very handie for flies with lots of images?
import bpy  #Original import Blender

from bpy import context, data, ops
#from ORIGINAL from Blender import Texture, Image, Material

#insert the path which should be replaced
oldpath = &quot;C:\\OLDpath\\&quot;

#insert the new path which replaces the old one
newpath = &quot;D:\\NewPth\\&quot;

image_count = 0

for tex in bpy.data.textures.get():

    image = tex.getImage()
    #print image.name

    filename = &quot;&quot;


    if (tex.getType() == &quot;Image&quot;):

        if (len(image.getFilename()) &gt; 0):

            i=0
            while i &lt; len(image.getFilename()) :

                if image.getFilename()[i:i+1] == &quot;\\&quot; :
                    filename += &quot;/&quot;
                else :
                    filename += image.getFilename()[i:i+1]
        
                i+=1

        if (oldpath == filename[0:len(oldpath)]):

            temp = filename[len(oldpath):len(filename)]
            temp = newpath + temp
    
            image.filename = temp
            image.reload()
        
            image_count += 1
        
print (&quot;image path's changed:&quot;)
print (image_count)

I did a few changes, but cant find the rest od my errors.
I thing some stuff is now depricated but I cant find the 2.8 Version
here is the Path to the ORIGINAL Script
https://blenderartists.org/t/script-to-change-paths-for-all-images/460733
You are right, this script is severely outdated (2009 !) This should do :
import bpy

# The path which should be replaced
oldpath = &quot;C:\\OLDpath\\&quot;

# The new path which replaces the old one
newpath = &quot;D:\\NewPth\\&quot;

image_count = 0

for image in bpy.data.images:
    if not image.filepath.startswith(oldpath):
        continue
    image.filepath = image.filepath.replace(oldpath, newpath)
    image.reload()
    image_count += 1

print(f&quot;Image paths changed: {image_count}&quot;)

We take advantage of the python string method string.replace(old_string, new_string) to swap the paths. Note that they must both be written the same way, like in your example.