Sub topic 7
Output paths and frame-number padding
This chapter covers where Blender writes rendered files and how it names them. It assumes you can use the Properties editor and the Timeline, and that you have set a resolution and file format in the Output properties. The chapter explains the path field, relative and absolute paths, the # padding characters, and the rules that decide whether frames overwrite each other or sit in the right order.
Where the path lives
The output path is stored per scene in scene.render.filepath. In the interface it is the Output field in the Output Properties tab. It is the base location Blender uses when it renders an animation, and it is the default suggestion when you save a still.
Two points affect everything that follows:
- When you render a still with Render ▸ Render Image and then save it from the Image Editor, Blender opens a file browser. The path field is not used automatically in that case.
- When you render an animation, or call
bpy.ops.render.render(write_still=True)from a script, Blender writes straight toscene.render.filepathwith no confirmation.
Relative and absolute paths
Blender accepts two kinds of path.
| Kind | Example | Meaning |
|---|---|---|
| Relative | `//renders/still.png` | `//` stands for the folder that contains the saved `.blend` file |
| Absolute | `/home/ana/project/renders/still.png` or `C:\project\renders\still.png` | A fixed location on the disk |
Relative paths keep a project portable. If you move the project folder to another machine, the renders folder still ends up next to the .blend file. Absolute paths break when the folder layout changes, and they differ between operating systems.
A relative path needs a saved .blend file. In an unsaved file there is no folder to resolve // against, and Blender falls back to a temporary location. Save the file first.
In a script, bpy.path.abspath() converts a // path into a full path. Use it when you want to check where a file will go.
import bpy
scene = bpy.context.scene
scene.render.filepath = '//renders/shot_'
print(bpy.path.abspath(scene.render.filepath))The printed line shows the resolved location. If the .blend file is unsaved, the result is not what you expect, which is a quick way to catch the problem.
Folders are created for you
Blender creates missing folders in the path when it writes a render. If //renders/ does not exist, a render to //renders/frame_#### creates it. This is convenient. It also means a typo such as //rendres/ creates a new folder instead of raising an error, so you can end up with output in two places.
Filename or folder?
The final part of the path decides whether Blender treats the value as a folder or as a file prefix.
- A path that ends in a separator, such as
//renders/, is a folder. Blender names each file with only the frame number, for example0001.png. - A path that ends in text, such as
//renders/shot_, is a prefix. Blender appends the frame number, givingshot_0001.png.
The second form is easier to identify later, so prefer it. A folder full of files named 0001.png through 0240.png is hard to tell apart from another shot's output.
Frame-number padding with `#`
When you render an animation, each frame becomes a separate file, so Blender needs to put the frame number in the name. The # characters in the path say where the number goes and how many digits it has.
| Path | Frame 7 becomes | Frame 120 becomes |
|---|---|---|
| `//renders/frame_####` | `frame_0007.png` | `frame_0120.png` |
| `//renders/frame_###` | `frame_007.png` | `frame_120.png` |
| `//renders/frame_#` | `frame_7.png` | `frame_120.png` |
Each # is one digit position. Blender fills unused positions with leading zeros. If a frame number has more digits than there are # characters, the number is written in full and is not truncated. Frame 12000 with #### becomes frame_12000.png.
Why padding matters
Most tools sort filenames as text, not as numbers. Without padding, the text order of frames 1, 2, 10 and 100 is wrong:
frame_1.pngframe_10.pngframe_100.pngframe_2.png
With four-digit padding the order matches the frame order: frame_0001.png, frame_0002.png, frame_0010.png, frame_0100.png. File browsers, video editors, and compositing tools that load a sequence by pattern all rely on this. Choose enough # characters for the highest frame number you expect. Four digits handles up to frame 9999, which suits most shots.
No `#` in the path
If you leave out the # characters on an animation render, Blender adds the frame number to the end of the name, padded to four digits. A path of //renders/shot_ gives shot_0001.png. Writing the # characters yourself is still useful, because it lets you choose the width and keeps the intent visible in the project.
Where the number sits
The # block can appear in the middle of a name. With //renders/shot_####_final, frame 3 becomes shot_0003_final.png. Blender also adds the file extension for you, so you do not type .png for an animation. Typing it into the path can produce a doubled extension such as frame_0001.png.png, depending on settings. Leave the extension out and let the file format choose it.
If you do not want the extension, or you want it to follow the format, check File Extensions in the Output properties. It is on by default.
Stills and the path
For a still, the # characters are not needed, since there is one frame. Compare the two cases in code.
import bpy
scene = bpy.context.scene
scene.render.image_settings.file_format = 'PNG'
scene.render.filepath = '//renders/still.png'
bpy.ops.render.render(write_still=True)With write_still=True, Blender writes the file at the given path. The extension in the path is kept as typed, so still.png stays still.png. If the path were //renders/still, the file would be named still.png because the extension is added from the format.
For an animation, the same field acts as a prefix:
import bpy
scene = bpy.context.scene
scene.frame_start = 1
scene.frame_end = 48
scene.render.image_settings.file_format = 'PNG'
scene.render.filepath = '//renders/shot_####'
bpy.ops.render.render(animation=True)This produces shot_0001.png through shot_0048.png in the renders folder next to the .blend file.
Overwriting and keeping old renders
Blender does not warn you before it replaces a file. The Overwrite option in the Output properties controls this behavior. It is on by default. With it on, a second render of the same frames replaces the first.
You have three ways to protect earlier work:
- Change the path for each version, for example
//renders/v02/shot_####. - Turn Overwrite off. Blender then skips frames whose files already exist, which is also how you resume an interrupted render, because only the missing frames are rendered.
- Turn on Placeholders. Blender creates an empty file for each frame at the start of its render. Several machines can then share one output folder, since each machine skips frames that another has claimed.
The skipping behavior in option 2 has a side effect. If you change the scene and render again with Overwrite off, Blender sees the old files and renders nothing. The result looks as if the render finished instantly. This is a common reason for "my changes do not show up in the render".
Frame numbers and the frame range
The number in the file name is the scene frame number, not a count starting at one. If the range is 101 to 148, the files are shot_0101.png to shot_0148.png. A later tool that expects a sequence to start at 1 or 0 will not find the first file. Either set the sequence start in that tool or render a range that begins where you need it.
Negative frame numbers are written with a minus sign, which makes the name longer than the padding suggests. Avoid negative ranges for output you plan to load as a sequence.
Video output and the path
When the file format is FFmpeg Video, the output is one file instead of many. The # characters are not used for numbering. Blender uses the path as the video file name and adds the container extension, such as .mp4.
A video whose path ends in a prefix such as //renders/clip_ is named with the frame range appended, so a range of 1 to 120 gives clip_0001-0120.mp4. This naming is easy to overlook when you look for a file called clip_.mp4.
Command-line paths
On the command line, the -o option sets the same path. It must come before the frame options, because Blender reads its arguments in order and a later -o does not change a render that has already been set up.
blender -b scene.blend -o //renders/frame_#### -F PNG -x 1 -s 1 -e 48 -aThe -x 1 option tells Blender to add the file extension. The // prefix still refers to the folder of scene.blend, not to the folder you ran the command from. Quote the path if it contains spaces.
Common path mistakes
| Symptom | Likely cause |
|---|---|
| No file appears where expected | The path is relative and the `.blend` file was never saved |
| Output lands in a new, misspelled folder | A typo in the path, since Blender creates missing folders |
| Frames sort out of order in another tool | Too few `#` characters |
| Files are named `0001.png` with no prefix | The path ends in a separator |
| Doubled extension | The extension was typed into an animation path |
| Render finishes at once with no output | Overwrite is off and the files already exist |
| Sequence tool cannot find the first frame | The frame range does not start where the tool expects |
Exercise
A scene has the frame range 95 to 105 and the output path //out/take_##. What are the first and last file names with a PNG format, and why might a sequence loader that expects four-digit numbers fail on them?
Show answer
The first file is take_95.png and the last is take_105.png. Two # characters pad to two digits, so frame 95 uses two digits and frame 105, which has three, is written in full without truncation. The names then have different digit counts, so a text sort places take_105.png before take_95.png, and a loader that expects a fixed width such as four digits will not match them. Using #### gives take_0095.png to take_0105.png, which sort correctly.
Exercise
You change the lighting in a scene and render an animation to the same folder as yesterday. The render finishes in a few seconds and the images are unchanged. What setting most likely caused this, and how do you fix it?
Show answer
The Overwrite option in the Output properties is off, so Blender skipped every frame whose file already existed. Turn Overwrite on to replace the old frames, or render to a new folder such as //renders/v02/shot_####.