1
$\begingroup$

So I have multiple cameras for different angles in my scene. I want the output file to be something like: renders\CAMERANAME\framenumber.png

It would be nice if this could be done automatically - currently I'm just typing the camera name in by hand, but I would like to streamline this so if I switch cameras it changes the folder for me.

I have been trying to use python but I am not very good and not sure how to do what I want.

this is as far as I got(not very far haha)

import bpy
import os

scn = bpy.context.scene

path = scn.render.filepath
cam = scn.camera

scn.render.filepath = path + cam +scn.frame
$\endgroup$
1
  • $\begingroup$ Have you tried with: camPath = os.path.join(path, cam.name, str(scn.frame_current)) scn.render.filepath = camPath $\endgroup$
    – Noob Cat
    Mar 27, 2021 at 4:52

1 Answer 1

1
$\begingroup$

the script automatically creates the directories with your cams names. If it is already there, the script just puts the animated pics in these folders.

check this out:

import bpy
import os

scene = bpy.context.scene

oldPath = bpy.context.scene.render.filepath

for ob in scene.objects:
    if ob.type == 'CAMERA':
        bpy.context.scene.camera = ob
       
        filepath = bpy.context.scene.render.filepath
       
#        filepath = bpy.data.filepath # blend file
        directory = os.path.dirname(filepath)
       
        name = ob.name + "/"

        directory_to_test = os.path.join(filepath, name)

        if not os.path.exists(directory_to_test):
            os.makedirs(directory_to_test)
            print("created directory: ", directory_to_test)
            
        file = directory_to_test + "render"
            
        bpy.context.scene.render.filepath = file
        
#        bpy.ops.render.render( write_still=True )
        
        bpy.ops.render.render(animation=True) 
        
        bpy.context.scene.render.filepath = oldPath
$\endgroup$

You must log in to answer this question.

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