Nuke Tips – Retrieve File Path List for Read Nodes

Retrieving File Path List for Read Nodes for Anyone

This is more for folks who need to know which renders or footages that they are currently using in their Nuke script.

To run the Python script, simply copy and paste the following codes into the Script Editor panel and execute it!

…fine I’ll show you a step-by-step to ensure it works for you (basically a pet peeve of mine when others wrote scripts but never document a simple idiot-proof guide that actually works).

  1. Launch Nuke.
  2. Copy the script from below (or from my GitHub repo).
  3. Paste it into the Script Editor panel.
  4. Select all the codes and press Ctrl + Enter for Win/Linux or Cmd + Return for Mac.
  5. ???
  6. Profit!

Codes

# Return filepath list for Read nodes in the current Nuke script
# Huey Yeng, 2018, https://taukeke.com/
"""Return filepath list for Read nodes.

Return every Read nodes' filepath. Useful for project cleanup to identify
files that are currently being use in the current script.

Returns:
List of valid filepaths.

Todo:
* Include ReadGeo nodes

"""
import nuke

nodes = nuke.allNodes('Read') # Grab all nodes with the class 'Read'. Valid classes include 'Write', 'ReadGeo', etc
source_list = [] # Initialised empty list

for node in nodes:
path = node["file"].value() # Retrieve value from "file" attribute
name = (path.split("/"))[-1] # Access the last value in array for path after splitting it with "/" delimiter
source_list.append(name) # Add/append name into source_list

result = "\nList of Read nodes:\n"
print(result)

for name in sorted(source_list):
print(name)

Expected Result

# A typical sample from Project DQ
# Result:
List of Read nodes:

TexturesCom_Skies0354_31_M.jpg
fFIR_FireA_v001.%04d.exr
fFIR_FireB_v001.%04d.exr
fFIR_FireC_v001.%04d.exr
fSMK_SmokePlumeA_v001.%04d.exr
fSMK_SmokeSmallA_v001.%04d.exr
fSMK_SmokeSmallB_v001.%04d.exr
s002c002_BG_Beauty_v001.%04d.exr
s002c002_BG_Debris_Beauty_v001.%04d.exr
s002c002_BG_Debris_bgShadow_v001.%04d.exr
s002c002_BG_Mask_v001.%04d.exr
s002c002_BG_WetDock_v001.%04d.exr
s002c002_Comp_0402_v001.mov
s002c002_FX_Droplet_Beauty_v002.%04d.exr
s002c002_FX_Mist_Beauty_v001.%04d.exr
s002c002_FX_Ocean_Beauty_v002.%04d.exr
s002c002_FX_Ocean_bgShadow_v001.%04d.exr
s002c002_FX_Ocean_bgWetmap_v001.%04d.exr
s002c002_FX_Sparks_Beauty_v001.%04d.exr
s002c002_FX_Splash_bgWetmap_v001.%04d.exr
s002c002_FX_SprayMesh_Beauty_v002.%04d.exr
s002c002_FX_SprayMesh_bgShadow_v001.%04d.exr
s002c002_FX_SprayPoints_Beauty_v001.%04d.exr
s002c002_FX_Spray_Beauty_v002.%04d.exr
s002c002_FX_Spray_Depth_v001.%04d.exr
s002c002_FX_Whitewater_Beauty_v001.%04d.exr
s002c002_Proxy_v001.%04d.exr
s002c002_Utility_v001.%04d.exr
s002c002_Utility_v001.%04d.exr
s002c002_Vehicles_Beauty_v001.%04d.exr
s002c002_Vehicles_PanelOnly_v001.%04d.exr
s002c002_Vehicles_bgShadow_v002.%04d.exr

What Should I Do Next?

You can use the result to help identify the read nodes in your script so you can safely move or delete any unused renders from your storage.

Basically there are endless opportunity like discovering the wonder of Python scripting for Nuke, bragging rights to your fellow colleagues or classmates that you have succeeded in running a custom Python script in Nuke and so on!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.