Render image path issues

Firstly, is the ‘Render’ button supposed to save an image?

‘Anim’ will save images, but I can’t get rid of the numbering. I only have one frame. If I leave out any ‘#’ characters from the image path, it will write as ‘<image>0001.png’, if I include a single #, it will write as ‘<image>1.png’.
Is there a way to make it output the exact path?

I was also wondering if there was a way to do it in a script for different scenes.

This is my script so far:

import Blender
from Blender import *
from Blender.Scene import Render

root = Scene.Get()
for scn in root:
    context = scn.getRenderingContext()
    context.renderPath = "//render/" + scn.getName() + "#.png"
    context.renderAnim()
    # This doesn't work - it asks for input which the user cannot give it in the console window
    #context.saveRenderedImage(scn.getName() + "#.png")
    Render.CloseRenderWindow()
    

Basically, I need to:

  • Iterate each scene
  • Render each scene
  • Save each render image to a path based upon the scene’s name (WITHOUT the numbering)

The Render button does not save an image. That’s a separate process (F3 key). Using the Anim button will always append a frame number. Not sure about the scripting.

I know F3 does it - forgot to mention that. Now I suppose the best idea would be to do whatever F3 does, but instead of showing the file browser, simply save the image (in the script).

Got it working… though it’s a bit hacky.

import Blender
import os
from Blender import *
from Blender.Scene import Render

renderdir = Blender.Get("renderdir")

root = Scene.Get()
for scn in root:
    context = scn.getRenderingContext()
    
    path = renderdir + "/" + scn.getName() + "#.png"
    context.renderPath = path
    
    context.renderAnim()
    Render.CloseRenderWindow()
    
    path = renderdir + "/" + scn.getName() + "1.png"
    pathnew = renderdir + "/" + scn.getName() + ".png"
    print(path)
    print(pathnew)
    
    if os.path.isfile(pathnew):
        os.remove(pathnew)
    
    os.rename(path, pathnew)