Here's the script:
And an example collected job:
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:
##syntax - run script on Nuke file
echo "Enter path for script collection or drag folder in Terminal window and hit Enter:";
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
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.