Upgrading an Old Python Script : Change all Image Paths at once
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.