n = nuke.thisNode()
oValue = n['file'].evaluate()
(prefix, v) = nukescripts.version_get(oValue, 'v')
v = int(v)
n['file'].setValue(nukescripts.version_set(oValue, prefix, v, v + 1))
A few lines of python code I wrote to put in the beforeRender knob in Write node Python tab for auto versioning. That is if the file name matches the format of “_v##” frame padding digit doesn’t matter, each file will go up a version if the file already exists.
For my usage, this code still has a few flaws.
- It doesn’t version up to the latest version.
- Because of above, it will overwrites the next version if it already exists.
- It will overwrite the file value to an absolute path.