Q100154: Relative file path referencing in Nuke
This article contains information on how to use relative file paths in Nuke.
There are two main ways to specify file paths in Nuke:
- Absolute paths
Absolute paths contain the full path name, so for example on Windows it would look like:
- Relative paths
Relative paths only contain part of the path up to a common relative point, for example:
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:
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:
you would have:
- relative path in the Read node set to:
The resulting absolute path would be:
The image below shows the file structure of this project:
We're sorry to hear that!Please tell us why.