Render and saving multiple images with different textures

Hi,

I have a scene where I want to evaluate different prints on an object. What I want to do is write some kind of script or just execute a command that:

  1. Renders and saves the first image.
  2. Changes the texture on the material
  3. Renders next image
  4. … and so on.

I figure this must be fairly simple and would save me a lot of time.
So the question is, how do I make this happen?

/Jonatan


import bpy
import os

scene=bpy.context.scene

dir_path,filename=os.path.split(scene.render.filepath)
     
slot=0
mat=bpy.data.materials['yourMaterial']
texture_strings=(
            'yourTexture.000',
            'yourTexture.001'
            #...
            )
          
for i,id in enumerate(texture_strings):
    texture=bpy.data.textures[id]
    mat.texture_slots[slot].texture=texture
    scene.render.filepath=os.path.join(dir_path,filename+"%#03d"%i)
    bpy.ops.render.render(write_still=True)

#restore    
scene.render.filepath=os.path.join(dir_path,filename)