Write node auto versioning

n = nuke.thisNode()
oValue = n['file'].evaluate()
if os.path.isfile(oValue):
(prefix, v) = nukescripts.version_get(oValue, 'v')
v = int(v)
n['file'].setValue(nukescripts.version_set(oValue, prefix, v, v + 1))
nuke.scriptSave()

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.

    1. It doesn’t version up to the latest version.
    2. Because of above, it will overwrites the next version if it already exists.
    3. It will overwrite the file value to an absolute path.

Leave a Reply

Your email address will not be published. Required fields are marked *