PDA

View Full Version : I made a job collection script for Nuke


cgbeige
08-10-2010, 07:23 PM
If you're like me, your source materials and nuke working folder is kind of crazy by the end of a project so I wrote a shell script for OS X/Linux that collects the source material and scene file for Nuke and writes them to a collection directory you specify. It copies your script unaltered and doesn't change your files in any way.

Here's the script:
http://www.can-con.ca/downloads/nukecollectscript.zip

And an example collected job:
http://grab.by/grabs/ad1f84142aee3c54aa97013fae00b1dd.png

Usage: drag the script into the shell (or copy it to a bin directory and run it like an app) and drag in a Nuke scene script. It just uses a simple shell script to read the Nuke file and pare down the Read files and all %04d type things to collect all nodes, OBJ type geometry included. It doesn't delete anything and the script is very clear in what it does:

#!/bin/bash
##syntax - run script on Nuke file

echo "Enter path for script collection or drag folder in Terminal window and hit Enter:";
read writeDir;
echo Script will now collect all files and Nuke script to this folder: $writeDir;
mkdir "$writeDir/source_images_films_and_geo" &

##Build file list from Nuke script
cat $1 | sed '/Write/,/}/d' | grep file | grep -v file_type | sed 's/%0[0-9]d/*/g' | sed 's/file //' | sed "s%.*%cp -iR & '$writeDir/source_images_films_and_geo'/%" > /tmp/nukeCollection.sh;

chmod +x /tmp/nukeCollection.sh;

##copy files and script to destination
/tmp/nukeCollection.sh;
cp -i $1 "$writeDir/" ;



This doesn't collect output from Write nodes to save space and keep things from being redundant (but I'm going to add a collect Write nodes option as well - it's just a matter of removing a sed pipe and offering a yes/no option). I eventually want to make it less "all your stuff in one folder" but it's better than nothing. I also want to make a copy of the collected script relinked to the collected files. Tested in OS X 10.6.4 and Ubuntu 10. Doesn't work in Windows since it's using the *NIX shell. Enjoy.

If anyone wants to help me improve it, go ahead - I'm not much of a coder. It should be pretty bullet proof against source file naming conventions.

pingking
08-10-2010, 09:39 PM
dont forget to share it at nukepedia (http://www.nukepedia.com)

cgbeige
08-10-2010, 11:14 PM
cool - I'm just going to fix the spaces/illegal characters in paths problem and add a choice for Write nodes and post it.

cgbeige
08-14-2010, 09:02 PM
ok - script updated with a check for duplicate file names. If it sees you are trying to collect one or more files that have similar names (images/diffuse/render.exr, images/specular/render.exr for example) it will fail with a warning that this script is not recommended for this scene.

same link - I'll post to Nukepedia now.

CGTalk Moderation
08-14-2010, 09:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.