Here's one for stereo work (works for non-stereo as well):

def createWriteDir():  
     import nuke, os  
     import re  
     #view = nuke.thisView()  
     views = nuke.views()  
     file = nuke.filename(nuke.thisNode())  
     dir = os.path.dirname(file)  
     viewdirs = []  
     try:  
         if re.search('%V', dir).group():    # replacing %V with view name  
             for v in views:  
                 viewdirs.append(re.sub('%V', v, dir))  
     except:  
         pass  
     if len(viewdirs) == 0:  
         osdir = nuke.callbacks.filenameFilter(dir)  
         if not os.path.isdir(osdir):  
             os.makedirs (osdir)  
     else:  
         for vd in viewdirs:  
             osdir = nuke.callbacks.filenameFilter(vd)  
             if not os.path.isdir(osdir):  
                 os.makedirs (osdir)  
                 print 'Directory (with viewname) created: %s' % (osdir)
                 
nuke.addBeforeRender(createWriteDir)


On Apr 27, 2012, at 7:04 AM, Julien Chandelle wrote:

> you can put this in your menu.py 
> 
> def CreatePath():
>     file = nuke.filename(nuke.thisNode())
>     dir = os.path.dirname(file)
>     osdir = nuke.callbacks.filenameFilter(dir)
>     try:
>         os.makedirs (osdir)
>     except OSError:
>         pass
>         
>         
> nuke.addBeforeRender(CreatePath, nodeClass = 'Write')
> 
> On Fri, Apr 27, 2012 at 3:51 PM, Rich Bobo <richb...@mac.com> wrote:
> Hi,
> 
> I know that there are several tutorials and examples of using Python to 
> automatically create output directories for Write nodes, such as this:
> http://www.nukepedia.com/gizmos/python-scripts/nodegraph/autowrite/
> 
> What I'm wondering is if it's possible to use the Write node's "Python - 
> before render" field to do it?
> 
> 
> Thanks for any help!
> 
> Rich
> 
> 
> Rich Bobo
> Senior VFX Compositor
> 
> Mobile:  (248) 840-2665
> Web:  http://richbobo.com/
> 
> 
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
> 
> 
> 
> -- 
> Julien Chandelle
> GSM : +32 (0) 494 277 542
> julienchandelle.be
> @jimbiscuit || imdb
> || Nuke , AE & Fusion Compositor ||
> 
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to