COLLECT ALL OF A NUKE SCRIPT’S MEDIA USING WRAPITUP

March 2019

WrapItUp is an easy-to-use tool that can collect and relink almost all files required to make a Nuke script work on another machine.
It has a user interface if you run it in Nuke, it can be executed from a command-line window for batch operations, and it can be called using a Python function.

I made sure to cram the entire thing in just one Python file, so you can simply drag-and-drop the file it into Nuke’s script editor if you wish to use it just once.

Tested on Windows, Mac and Linux (CentOS).

 

 

Download
Settings
Command line
Python function

 

 

 

WrapItUp nuke collect all files

 

get all used files for nuke comp

Download

Features:

  • Three copies of the Nuke script will be collected: the original, a relinked one, and a relative-relinked one (using a python-embedded TCL expression).
    The relative-relinked Nuke script will stay linked to its media, even if you move it to a completely different machine – as long as the media is right next to it.
  • Media files with the path variables ####…, %**d (printf), %v and %V are supported.
  • Gizmos will be collected, and the necessary menu.py and init.py files will be generated. Simply place these files in your .nuke folder to install them.
  • A detailed CSV log file is generated to review which files were copied.

 

Not supported: Shared library plugins, e.g. .dll, .dylib and .so files.
There are simply too many dependencies and licenses involved to keep track of these.

Nuke installation

  1. Place the WrapItUp folder in your .nuke folder (or somewhere else on your computer)
  2. Go to your .nuke folder, and create a file called ‘init.py’. If such a file already exists, open it.
  3. In the init.py file, add this line of text to the end and save it:

nuke.pluginAddPath(‘./WrapItUp’)

If you want to place the folder somewhere else than in the .nuke folder, make sure to change the path in the init.py file so that it points to that other path instead!

 

 

Only run once (in Nuke)

If you are only running it once, you can simply drag-and-drop the WrapItUp/WrapItUp.py file into the script editor panel in Nuke and click ‘Run the script’.

 

 

Installation using NukeShared

  1. Place the WrapItUp folder in the ‘_AutoInstaller’ repository.

 

NukeShared is a way of installing plugins by dragging/dropping them in folders, see this page for more information.

Settings

First, choose the collection folder to which all collected files will be copied. Make sure this is an empty folder – this script will overwrite any pre-existing files.

 

nukescript wrapitup

 

 

All settings are set to copy everything by default.
To omit specific item types or change the way WrapItUp behaves, edit the following parameters:

 

 

– media

 

make nuke script copy, relinked

Make another copy of the Nuke script in which all nodes that have their media copied over will be relinked.

 

make nuke script copy, relative relinked

Make another copy of the Nuke script in which all nodes that have their media copied over will be relinked using the following path prefix: [python {nuke.script_directory()}]

This way, the nuke script will keep working, even if it has been moved to a different location/machine – as long as the media files are right next to it.

 

place media in folder with node name

Place all media items in a subfolder with its corresponding node as that folder’s name.

This helps finding which media belonged to which node in the new comp, and it is an extra measure against the kind of problems that could arise when parent folders of different media items have the same names.

 

parent directories

The amount of (empty) parent directories to copy over for each found media item.

For instance:
An image sequence in /path/to/image/files/file_####.exr with a parent directory count of 3 will have the following destination in the final collected path:

../MEDIA/image/files/file_####.exr

If the ‘place media in folder with node name’ checkbox is unchecked, do not make this number too small.
Fiiles with same-name parent directories might end up overwriting, or merging together.

 

– add-ons

 

copy font directory (if any)

If the current Nuke script has a custom Project Font Path set in Settings > Node, collect this directory.

 

copy gizmos

If custom gizmos are used in this Nuke script, collect them and generate an init.py and menu.py file that installs them on a different machine.

This function does not work for all gizmos, as they can be dependent on other files.
This does not work for plugins (.dll, .so, .dylib).

 

– misc

 

continue on error

Continue copying if an error occurs.
If there are errors, check the log.txt file generated in the selected root folder.

 

exit nuke on finish

Close Nuke entirely when the copying process is finished (or on error, if ‘continue on error’ is disabled).

Useful for machines that are licensed using a limited number of floating licenses on a license server.

 

CSV separator

Set the log file’s CSV column separator.

The ‘copy’ list (left) will show all items that will be copied to the new location.
Use the arrow buttons at the bottom to move them over to the ‘ignore’ list, if these items do not need to be copied.

Use the ‘Start’ button to begin copying all files.

When the copying process has started, a progress bar will appear to indicate how much time it will take.
As nuke scripts usually use many gigabytes of data, it could take a while. Leave Nuke open for as long as this process takes.
If you want Nuke to exit at the end of the process due to floating licenses that might be needed elsewhere, check the ‘exit nuke on finished’ box.

 

 

 

nuke get media for nukescript wrap it up

 

 

 

 

 

WrapItUp can be called as a start-up script for the Nuke command line, so you can run it inside a terminal/console/command prompt window.
It is also a Python module that can be imported in a Python script or run from a Python shell.

In both cases you will need a licensed Nuke installation on the machine you are running WrapItUp on in order for it to work.
Use the instructions down below to run WrapItUp through command line or Python.

Command line

As Nuke can be run from command line with a Python script attached to it, I made sure to support this for WrapItUp as well.
This is what the command line looks like:

 

<nuke installation> -t <WrapItUp.py> <WrapItUp arguments>

 

The -t is an argument to make Nuke start without a UI. (It needs to be there.)

 

 

WrapItUp arguments:

 

-nk <nukescript path> (required)
-o <output folder> (required)
-s (start now – if not, only a preview list of the files to be processed will be returned)
-n (disable: place media in node name folder)
-pd <parent directory count> (default: 3)
-r (disable: make relinked .nk)
-rr (disable: make relative relinked .nk)
-m (disable: collect media)
-f (disable: collect font folder)
-g (disable: collect gizmos)
-csvcomma (use commas instead of semicolons as the CSV separator)

 

 

Example command line (Windows):

“C:\Program Files\Nuke11.2v3\Nuke11.2.exe” -t “C:\Users\Max\WrapItUp\WrapItUp.py” -nk “\\remote-storage\work\scripts\0001.nk” -o “C:\Users\Max\Collected_Scripts\0001” -pd 10 -s

 

This will start collecting files for the Nuke script “\\remote-storage\work\scripts\0001.nk”, to the folder “C:\Users\Max\Collected_Scripts\0001”. All media will be placed in a path of 10 parent directories deep.
If you omit the -s in this line, the copying process will not actually start. Only a preview of what would happen will be printed.

Python function

Simply import the WrapItUp module and call WrapItUp.WrapItUp() – without any arguments, this will open the user interface window.
If the ‘out’ argument has been set (see list of arguments below), the UI will not show and the script will instead run silently following the arguments that were entered.

 

Python arguments:

 

nk (string)

Path to nuke script file (.nk) to collect.
Default: current nuke script, if running in Nuke.
Required: only if not running in Nuke.

out (bool)

Collection folder path.
Required.

startnow (bool)

Starts the copying process right away. If false, running the function will only return a preview of which files will be processed.
Default: False.

nodenamefolder (bool)

Place media in folder with node name.
Default: True.

parentdircount (int)

Parent directories.
Default: 3

relinked  (bool)

Make nuke script copy, relinked.
Default: True

relativerelinked (bool)

Make nuke scrip copt, relative relinked.
Default: True.

media (bool)

Copy media.
Default: True.

fonts (bool)

Copy fonts directory (if any).
Default: True.

gizmos (bool)

Copy gizmos.
Default: True.

csvcommas (bool)

Set the log file’s CSV separator to commas instead of semicolons.
Default: False.

Example Python function call:

 

 

This will collect the file /user/documents/nukescript/v001.nk to the folder /user/documents/collected, with 10 parent directories for each media item.

If you encounter any problems with missing Nuke modules, make sure Nuke and Python are both added correctly to the environment variables.
(On Windows, I had to manually add both the Nuke installation directory to PATH, and the Nuke/lib/site-packages to the PYTHONPATH variable.)

If you have any questions/suggestions, let me know!