edited tags
Marty Fouts
• 31.5k
• 10
• 29
• 70
edited title

# How can we add to the rendered object name with his material name?

corrected code formatting.
Gorgious
• 26.7k
• 2
• 31
• 81

Thanks to @FFeller, how helped me to automate a rendering of an object with the associated list of material. And Thanks to @Marty Fouts, how helped me with a script for renaming a rendered images with there associated materials. It works perfectly if the generated names are made by default. – link bellow – But I have many objects to render with the specific names, generated by a Compositing Output file, and the script looks for names like – 0000.png – and didn’t recognize names like – CUBE_ONE_0000.png – Knowing that I have a small knowledge of Python, can you please @Marty Fouts, help me to adjust the scripts. Images to illustrate my needs, hoping that I made it clear😊 Thanks a lot.

How can I render an object in a different material, each one in a separate image?

How can we render an object including his material name?

    import bpy
from pathlib import Path

scene = bpy.context.scene
path = Path(scene.render.filepath)
suffix = ".png"

object = bpy.context.active_object
for index in range(len(object.material_slots)):
src_string = format(index, "04d") + suffix
src = path / src_string
dst_string = object.material_slots[index].material.name  + suffix
dst = path / dst_string
print(str(src), str(dst))
src.rename(dst)
$$$$
`
corrected code formatting.