ok… first. as you saw in the Datablocks, all the images are in one Datablock called ‘images’.
The real path of this Datablock is ‘bpy.data.images’ , and in the console we can simply write ‘D.images’ and this will return a collection of BlendDataImages, which you can look and change.
For example the first image is ‘D.images’, the second ‘D.images’ , etc. Each image has lots of information inside (even all the pixels color are there and can be changed if you want!), but for now let’s just look at the filepath property.
(if you want to check what each element has inside, you can allways write ‘D.images.’ and press CTRL+Space to see the list)
Image has its filepath stored in ‘D.images.filepath’ and we can change it if we want to anything else.
so the script is just, in english:
For each image, that we will call ‘img’, in the collection D.images: (for img in D.images:)
because it’s a loop, the >>> will change to … and you can now say what to do for each image.
store the filepath of this image in a string variable, named ‘PathI’ (PathI=img.filepath)
now there’s a function inside every string variable that let us replace text inside the string, it works as string.replace(‘text to look for’, ‘text to replace’)
so if the initial string is ‘c:\oldfolder\filename.jpg’ and we want to set the path to ‘c:
ewfolder\filename.jpg’ , then we must write string.replace(‘c:\oldfolder\’, ‘c:
and we set the image.filepath to the result of the replace function ( img.filepath=PathI.replace(‘oldpath’, ‘newpath’) )
Images have also the function ‘pack()’ that as the name says, it packs the image. ( img.pack() )
of course if some images are in different folders, the ‘oldfolder’ string will not be found by the replace function. but you can change them manually.
In the end press enter twice to exit the ‘For’ loop, and it will execute automatically.
any doubts, you can allways check in the blender web site for the python api, or the python web site for more python specific functions. And of course the Python support here in BA