Q100154: Relative file path referencing in Nuke

SUMMARY

Relative paths only contain part of the path up to a common relative point, rather than the full absolute path. This means you can move the parent directory and your project will still work, as file paths are referenced relative to a common point.


How do I set up relative paths in Nuke?

  1. Open the Nuke script and go to Edit > Project Settings.
  2. Click Script Directory, which sets project directory to [python {nuke.script_directory()}].
  3. In Read and Write node file paths, use relative references from current script's location. Use ../ to navigate up directories from the script's location.

 

MORE INFORMATION

There are two main ways to specify file paths in Nuke:


Absolute paths:

Absolute paths include the complete path name; for example, on Windows, it would look like:

C:/Users/Admin/Documents/Nuke/Project001/Shot001/Frame_####.dpx

 

Relative paths:

Relative paths only contain part of the path up to a common relative point. For example:

Shot001/Frame_####.dpx

Where the rest of the path C:/Users/Admin/Documents/Nuke/Project001 would be provided as a relative reference that Nuke will fill in behind the scenes.

This means that you can move the parent directory location and all the files and your project will still work as the file paths are referenced relative to a common point.

 

Referencing relative paths:

The common relative path used to reference the full file path is defined in the project directory knob of the Nuke script.

This can either be set to:

  • an absolute path, or
  • the same directory as the one your Nuke script is saved in.

To edit the value of project directory:

  1. Open the Nuke script.
  2. Open the Project Settings, by selecting Edit > Project Settings.
  3. Press the Script Directory button. This will fill the project directory knob with the following code:
    [python {nuke.script_directory()}]

    This will set the project directory path to the same one where the Nuke script is stored.

When defining the project directory, the Read node file path reference is not required to only go down directories from the Nuke script location. You can also go up directories from the script's location by using ../.

This allows you to have your Nuke script in a sub-directory, yet still be able to use relative referencing to access all the required files, for example:

To reach the full project path of C:/Users/Admin/Documents/Nuke/Project001/Scripts/NukeScript_001.nk you would have:

  • project directory: [python {nuke.script_directory()}]
  • relative path in the Read node set to: ../Shot002/Frame02_####.dpx

The resulting absolute path would be: C:/Users/Admin/Documents/Nuke/Project001/Shot002/Frame02_####.dpx

The image below shows the file structure of this project:

 

 

    We're sorry to hear that

    Please tell us why