Q100273: How to handle path substitutions for Nuke terminal sessions
Warning: This article contains links to external websites
SYMPTOMS
You have set up your path substitutions under Edit > Preferences... in Nuke, but the file paths aren’t substituted correctly during command line rendering or Python Terminal mode. Your path substitutions would look like:
CAUSE
File paths may not be substituted correctly on a command line render or Python Terminal mode because Preferences aren't loaded when Nuke is run outside of GUI mode.
Terminal mode (without GUI) allows you to enter Python commands without launching the GUI.
A >>> command prompt is displayed during this mode. Command line mode (batch mode) allows you to run commands in the terminal to render your Nuke script (without GUI).
Please see the Nuke Online Help on Command Line Operations for more information.
RESOLUTION
To solve this, you can use the command line argument --remap, which will take a list of path substitution pairs and work only for the active Nuke session, or set a filenameFilter callback in your init.py file to have it persistent across all Nuke sessions.
Current Nuke session
Here is an example of how the flag is used when running Nuke in Terminal Mode:
nuke -t --remap "X:/path,Y:,A:,B:/anotherpath"
Where:
-
nukereferences the appropriate Nuke executable installation location:Windows: C:\Program Files\Nuke10.5v2\Nuke10.5.exe
OSX: /Applications/Nuke10.5v2/Nuke10.5v2.app/Contents/MacOS/Nuke10.5v2
Linux: /usr/local/Nuke10.5v2/Nuke10.5 - Any paths starting with
X:/pathare converted to start withY:. - Any paths starting with
A:are converted to start withB:/anotherpath.
To substitute paths between different operating systems, your command would look for example like:
nuke -t --remap "/home/project/shot/,C:/project/shot"
NOTE: The path mappings are only applied to the current Nuke session and they do not affect the Preferences.nk file used when running the Nuke GUI.
Multiple Nuke sessions
To make your path substitutions persistent across multiple Nuke sessions you can use the filenameFilter callback. More information on this can be found in the Nuke Python Developer Guide.