For example I want it to be something like: RenderedImage1.png RenderedImage2.png and etc How to do something like this?

Here's the code I have:

import bpy
from random import randint
from random import random
from random import uniform

ob = bpy.context.active_object

ob.particle_systems[-1].settings.hair_step = randint(0, 20)
ob.particle_systems[-1].settings.hair_step = randint(0, 20)

def render_image():
    if  bpy.context.scene.frame_current == 250:
        bpy.context.scene.render.filepath = 'BlenderRepository/RenderedImages/RenderedImage.png'
        bpy.context.scene.render.resolution_x = 1920
        bpy.context.scene.render.resolution_y = 1080


1 Answer 1


Just call RenderSettings.frame_path() which returns the absolute path to the filename for a given frame or concatenate your string like ".../folder/image_" + str(250) + ".jpg"(error prone due to OS differences).

Proof using the Console:

>>> rd = C.scene.render
>>> rd.frame_path(frame=250)

For multiple render iterations, I'd suggest append the iterator to the filepath:

C = bpy.context
rd = C.scene.render

for r in range(1,3):
    path, ext = rd.frame_path(frame=250).rsplit('.', 1)
    multi_path = path + "_" + str(r) + "." + ext
    print (multi_path)

Terminal Output:

  • $\begingroup$ The 250th frame is the frame I need, I cannot change it. I want to exe my script and get RenderedImage1.png. Then again I execute it once more and now i get RenderedImage2.png $\endgroup$
    – cxnt
    Jul 26, 2019 at 10:31
  • $\begingroup$ You don't have to change it, you just need to pass the integer to the function. Take your time and think about that @cxnt $\endgroup$
    – brockmann
    Jul 26, 2019 at 10:33
  • $\begingroup$ For whatever reason your comment changed... You want to have RenderedImage1.png instead of RenderedImage_0250.png? Why? @cxnt $\endgroup$
    – brockmann
    Jul 26, 2019 at 10:45
  • $\begingroup$ Because it looks better @brockmann $\endgroup$
    – cxnt
    Jul 26, 2019 at 10:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .