2
$\begingroup$

Lately I've been experimenting with importing rendered animation frames into a game engine which expects a very specific filename format consisting of four letters, followed by a fifth incremental letter, followed by a static numerical value.

NAMEA0.png
NAMEB0.png
NAMEC0.png

Is there a way to make it so blender automatically saves my rendered frames following this format? With frame 1 = A, frame 2 = B and so forth?

Thanks in advance.

$\endgroup$
2
  • 2
    $\begingroup$ What would happen with more than 26 Frames? $\endgroup$
    – Leander
    Commented Apr 29, 2019 at 9:45
  • 1
    $\begingroup$ Not natively as far as I know, but you could probably script it with python. Might just be easier to rename them using a third party tool. $\endgroup$ Commented Apr 29, 2019 at 15:34

2 Answers 2

1
$\begingroup$

Well, this is awkward, I just figured it out. I had looked at an answer to a similar question here, but having no experience with scripting, I thought I wouldn't know how to adapt it to my needs. Turns out that after looking at some basic python tutorials, I managed to write a script that, while not very elegant, definitely works. Here's the script in question:

import bpy
letter = 'A'
def handler_set_filepath_based_on_frame(scene):
    if scene.frame_current == 1:
        letter = 'A'
    if scene.frame_current == 2:
        letter = 'B'       
    if scene.frame_current == 3:
        letter = 'C'
    if scene.frame_current == 4:
        letter = 'D'               
    if scene.frame_current == 5:
        letter = 'E'
    if scene.frame_current == 6:
        letter = 'F'               
    if scene.frame_current == 7:
        letter = 'G'  
    if scene.frame_current == 8:
        letter = 'H'        
    if scene.frame_current == 9:
        letter = 'I'  
    if scene.frame_current == 10:
        letter = 'J'  
    scene.render.filepath = ("/tmp/NAME%s0#" % letter)


bpy.app.handlers.frame_change_pre.append(handler_set_filepath_based_on_frame)

I'll likely will never need to render more than 10 frames or so. So manually defining a variable for each isn't that much of a hassle.

Here's the answer from which I based my script off of. Changing filename format based on current animation frame?

$\endgroup$
1
$\begingroup$

You can do:

import bpy

def handler_set_filepath_based_on_frame(scene):
    letters = ['A','B','C','D','E','F','G','H','I','J','K']
    scene.render.filepath = ("/tmp/NAME%s0#" % letters[scene.frame_current])
    bpy.app.handlers.frame_change_pre.append(handler_set_filepath_based_on_frame)

then you don't have to care for each frame

$\endgroup$

You must log in to answer this question.

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