Automatical Filenaming on Render Output possible?


I have the following problem: I have lots of Scenes and lots of shots in those scenes. Every shot has about 5-10 renderpasses(layers and passes). So how is the most practical way to save these?

What I am doing now is set up a file-output node for every renderpass that i need. But this can be very tedious.

What would simplify this procedure (for larger scale productions) would be to be able to fill in kind of variables into the output filename and path of the fileoutput node in the compositor:


[output node] …/…/render/$blenderFilename/$sceneName/$renderlayer_$renderpassName_$frameNumber.exr[output Node]
This way I would have one set-up and wouldnt need to change the filenames every time.

Is there a way with python or via a plugin, I can achieve this effect?
Also, is there a way to create folders, that don’t exist via the fileoutput node?