(1 vote, average 4.00 out of 5)

Howdy. Just thought I'd share this snippet of a code with you guys. Enter this into the "onScriptLoad" of the project setting to automatically set the working directory to where the nuke file is located. This probably only works in Windows, so if someone gets working versions for the other OS, that would be great.

os.chdir(nuke.root().name()[0:nuke.root().name().rfind("/")])

Comments (2)

Ben Dickson said:

...
That should work fine on any OS.

It can be simplified a bit to:

os.chdir(nuke.root().name().rpartition("/")[0])

Or better:
os.chdir(os.path.dirname(nuke.root().name()))
January 22, 2012

Rich Bobo said:

...
Very nice - I was looking for something like this...

Rich
January 15, 2013

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy