Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When rendering, it can be useful to automate setting the output file path using existing data from within the blend file.

Is it possible to use variables in the render output path? eg,


Either from the interface or the command-line.

Note, this question is similar to How to show render-stamp for arbitrary values?

share|improve this question

While Blender has no build-in support for this feature. You can do this using Python:

From Within Blender

Add a script into your file, call it (for example).

  • Press Run Script (only need to do once)
  • Enable the Register option in the text editor (so it runs automatically).

Here is a sample script.

import bpy

def render_filepath_set(scene):
    scene.render.filepath = '{file}_{scene}_{camera}_####'.format(

From the Command-Line

A similar method can be used, by running a script from the command line, first create a file.

import bpy
scene = bpy.context.scene
scene.render.filepath = '{file}_{scene}_{camera}_####'.format('.')[0],,,

And run it with:

blender --background /d/untitled.blend --python --render-anim

Or, you can avoid using a Python file and simply pass in the script on the command line (using --python-expr).

blender --background /d/untitled.blend --python-expr "import bpy; scene = bpy.context.scene; scene.render.filepath = '{file}_{scene}_{camera}_####'.format('.')[0],,"

This isn't practical to manually type in of course, but can be used when running Blender as an automated task (shell script / bat file... etc).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.