how to link/reference the outputfilename to the .blend file name

Hi all,

does someone know how to create a variable in the output filename path in order to reference the filename of the blendfile?

for example: //output/exr/"$blendfilename_###"

so if my filename is “projectone.blend” my output file would be “projectone.exr”

I hope you understand what I mean :wink:

thanx for all your help in advance,

Sounds like a job for os.path.splitext()

import os
path_without_dotblend = os.path.splitext(blend_path_in)
path_with_exr = path_without_dotblend + '.exr'

import bpy
from os.path import splitext

    filename = bpy.path.basename(
    filename = splitext(filename) + ".exr"
    print("No filepath, unsaved blend?")

Thank you for the quick reply,

could I imput something like this directly in to the output field as an “expression” like in the screenshot (I know, it doesnot work like I did it ;(

thanks in advance,


There’s currently just “#” that acts as a placeholder for a number. I can’t remember for sure, but I believe there was a discussion once about what placeholders should be added. The most flexible approach would allow a python expression. Not sure how safe such an evaluation would be though.

You could try to use an app handler to set the output path before a frame is rendered, that might actually work well. # clear all app handlers if needed

def set_render_filepath(scene):

    # use any criteria and expression for dynamic render filepath here
    if scene.frame_current < 10:
        scene.render.filepath = "C:/tmp/below_ten_##"
        scene.render.filepath = "C:/tmp/ten_or_greater_##"


I have to admit I am a little lost here now,

I will have to look through that again :wink: