cgbeige
08-10-2010, 06: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.
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.
