Q100472: How to create a Batch render for Nuke on Windows

Follow

SUMMARY

This article explains how to create a Batch file for rendering multiple Nuke scripts on a Windows operating system. This would be beneficial for a user to implement the rendering of more than one script at a time, especially those with asynchronous frame output.


MORE INFORMATION

This process will allow the user to run a single Batch file to achieve the same results as opening multiple command windows to render with. This process is fairly complex, and requires working knowledge of Windows directories and specific Nuke command-line operations to complete.

Example:

1. Open a text editor, such as Notepad.

2. Begin scripting the batch file by adding a path to Nuke with the following code:

path="C:\Program Files\Nuke15.1v2\"  - using whichever version of Nuke is currently installed.

2a. Then, implement the script to be rendered with this line:

start Nuke15.1.exe -x -F 1-10 “path\to\the\script_v1.nk "

 NOTE: The start command opens Nuke 15.1 and then executes (-x) all Write nodes of the script for frames (-F) 1-10 in a specific script titled “test_v1.nk”.

2b. Repeat the above command for each specific script to be rendered. Please see the example below to reference this.

3. Save your script with File > Save As…

4. Create a filename with the extension .bat (i.e. "my_batchrender.bat") and confirm with Save.

5. Double-click the batch file in the saved location to run the script. Alternatively, right-click the file and select Open.

6. Once the batch file completes, view the specified directory for output of the renders.

 

Please view this example batch file for rendering 3 scripts at once, which also includes additional lines that are not referenced  above. You may view additional information regarding these lines in the Further Reading section and this script can also be downloaded from the Example File section:

Example Batch File...
@echo off
title Batch Render Nuke Scripts!
mode 45, 10

rem ======================
rem A CHOICE TO MAKE
rem ======================
echo.
echo WELCOME!
echo.
echo.

CHOICE /M "Would you like to begin rendering?"
IF ERRORLEVEL 2 GOTO :End
IF ERRORLEVEL 1 GOTO :Begin

rem ============================
rem BEGIN THE BATCH RENDER
rem ============================

:Begin
rem ======================================
rem SETTING PATH TO EXECUTE RENDER
rem ======================================

path="C:\Program Files\Nuke15.1v2\"

rem =========================
rem BEGIN SCRIPT 1 RENDER
rem =========================

start Nuke15.1.exe -x -F 1-10 "C:\temp\test_v1.nk"

rem =========================
rem BEGIN SCRIPT 2 RENDER
rem =========================

start Nuke15.1.exe -x -F 1-10 "C:\temp\test_v2.nk"

rem =========================
rem BEGIN SCRIPT 3 RENDER
rem =========================

start Nuke15.1.exe -x -F 1-10 "C:\temp\test_v3.nk"


:End
title No Renders made...
cls
echo.
echo.
echo.
echo NO RENDERS MADE, NOW EXITING!
PING localhost -n 2 >NUL
exit


Additional Notes:

With the above batch file example, the path of Nuke is set first for the program to initialize correctly. Then, the specific script locations for test_v1.nk, test_v2.nk, and test_v3.nk will open a command prompt for each file, and execute the specified frames called out in the start line.

Any command line operations that Nuke accepts can be used in the batch file, such as Render Order with -sro, or using specific Write nodes by using the -X command and the name of the Write node.

Additionally, it may be necessary to stagger the renders with another command called /wait. Using this command would begin the next script only after finishing the previous. An example of this would be used as: 

@echo off
rem ======================================
rem SETTING PATH TO EXECUTE RENDER
rem ======================================

path="C:\Program Files\Nuke15.1v2\"
 
rem =========================
rem BEGIN SCRIPT 1 RENDER
rem =========================

start /wait Nuke15.1.exe -x -F 1-10 "C:\temp\test_v1.nk"

rem =========================
rem BEGIN SCRIPT 2 RENDER
rem =========================

start Nuke15.1.exe -x -F 1-10 "C:\temp\test_v2.nk"

 

FURTHER READING

Please view our documentation for more details regarding Nuke's command line operations.

Please see the articles below for more information on Batch files:

 

EXAMPLE FILE

We're sorry to hear that

Please tell us why