1
$\begingroup$

I had to convert all my PNGs to JPGs, reason why now I need to switch to those new texture files. Batch converting the image files was easy and fast. But how to do the next step in Blender now?

Thanks in advance guys

DPC

$\endgroup$

1 Answer 1

5
$\begingroup$

You can replace the filepaths using python and then reloading the images:

import bpy
for img in bpy.data.images:
    img.filepath = img.filepath.replace('.jpg', '.png')
    img.reload()
$\endgroup$
3
  • $\begingroup$ Great! JuhaW from BlenderArtists suggested a similar solution, also with "import bpy": import bpy for i in bpy.data.images: i.filepath = i.filepath.replace('.png', '.jpg') What do you think? $\endgroup$ Mar 29, 2016 at 13:40
  • $\begingroup$ I did try your code, but I must be doing something wrong: Screenshot of error after running script: blenderartists.org/forum/… And this is a screenshot of the console: blenderartists.org/forum/… $\endgroup$ Mar 29, 2016 at 14:55
  • $\begingroup$ identation error means that you've missed the spaces at the beginning of the line. Python is very picky about those things, try copying the script exactly into your text editor, then it should work. $\endgroup$
    – Parkuhr
    Mar 30, 2016 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.