V-Ray file name prefix python script


Hello! I’m a beginner coder and I have a question about developing a python script that will edit the file name prefix of a file AFTER the tokens have been entered into the file name prefix box.

More specifically our problem is this: The way our pipeline is setup, when we save a scene, our software automatically saves with a new version number. So if we save a file called scene_0001 that uses the prefix tokens:


the files will render with this prefix"


when we save this file and go to render again, our pipeline will automatically increment to scene_v0002 during the save, making the new rendered files have this prefix:


This creates a folder and organization problem because it’s creating too many folders when we render and making things a mess. Our only fix for now is to keep manually naming prefixes before rendering. We want to keep the rendering process as streamlined as possible and remove the possibility of human error when manually renaming the render files. Would it be possible to make a script that can remove the _0001 from the file name? So the files will be called this when they are rendered:


My initial solution would be to stop giving the scenes version numbers, but that isn’t possible with our current pipeline setup.

I’m not even sure if this is possible to do with code. With my limited knowledge on the subject the only thing i can think of is a script that intercepts the output files, searches the script for a specific string, and then deletes the unnecessary strings… but I have no idea how to execute this!

Thank you for your time!