Automatically create folders when rendering

Hi all,

Just wanted to share a very simple script that creates the folder structure defined in the Write node. This can be very usefull when using folders with version numbers or whatever. You won’t get the "Write1: Can’t write, no such directory" error anymore. But be carefull with typo’s!

In menu.py add:

Code:


def createWriteDir():
 import os
 file = nuke.filename(nuke.thisNode())
 dir = os.path.dirname(file)
 osdir = nuke.callbacks.filenameFilter(dir)
 try:
  os.makedirs(osdir)
 except OSError:
  pass


Then in a write node you could manually add: createWriteDir() in the before render input box (Python tab). Or set it as default value for new Write nodes (also in menu.py):

nuke.knobDefault(‘Write.beforeRender’,’createWrite Dir()’)

It should be os independent, I only tested it on Linux and Mac.

No Responses to “Automatically create folders when rendering”

Post a Comment