PostsNuke TipsDemo ReelGalleryResumeAbout

Nuke Tips – Retrieve File Path List for Read Nodes

Huey Yeng

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

1# Return filepath list for Read nodes in the current Nuke script
2# Huey Yeng, 2018, https://taukeke.com/
3"""Return filepath list for Read nodes.
4
5Return every Read nodes' filepath. Useful for project cleanup to identify
6files that are currently being use in the current script.
7
8Returns:
9List of valid filepaths.
10
11Todo:
12* Include ReadGeo nodes
13
14"""
15import nuke
16
17nodes = nuke.allNodes('Read') # Grab all nodes with the class 'Read'. Valid classes include 'Write', 'ReadGeo', etc
18source_list = [] # Initialised empty list
19
20for node in nodes:
21path = node["file"].value() # Retrieve value from "file" attribute
22name = (path.split("/"))[-1] # Access the last value in array for path after splitting it with "/" delimiter
23source_list.append(name) # Add/append name into source_list
24
25result = "\nList of Read nodes:\n"
26print(result)
27
28for name in sorted(source_list):
29print(name)

Expected Result

1# A typical sample from Project DQ
2# Result:
3List of Read nodes:
4
5TexturesCom_Skies0354_31_M.jpg
6fFIR_FireA_v001.%04d.exr
7fFIR_FireB_v001.%04d.exr
8fFIR_FireC_v001.%04d.exr
9fSMK_SmokePlumeA_v001.%04d.exr
10fSMK_SmokeSmallA_v001.%04d.exr
11fSMK_SmokeSmallB_v001.%04d.exr
12s002c002_BG_Beauty_v001.%04d.exr
13s002c002_BG_Debris_Beauty_v001.%04d.exr
14s002c002_BG_Debris_bgShadow_v001.%04d.exr
15s002c002_BG_Mask_v001.%04d.exr
16s002c002_BG_WetDock_v001.%04d.exr
17s002c002_Comp_0402_v001.mov
18s002c002_FX_Droplet_Beauty_v002.%04d.exr
19s002c002_FX_Mist_Beauty_v001.%04d.exr
20s002c002_FX_Ocean_Beauty_v002.%04d.exr
21s002c002_FX_Ocean_bgShadow_v001.%04d.exr
22s002c002_FX_Ocean_bgWetmap_v001.%04d.exr
23s002c002_FX_Sparks_Beauty_v001.%04d.exr
24s002c002_FX_Splash_bgWetmap_v001.%04d.exr
25s002c002_FX_SprayMesh_Beauty_v002.%04d.exr
26s002c002_FX_SprayMesh_bgShadow_v001.%04d.exr
27s002c002_FX_SprayPoints_Beauty_v001.%04d.exr
28s002c002_FX_Spray_Beauty_v002.%04d.exr
29s002c002_FX_Spray_Depth_v001.%04d.exr
30s002c002_FX_Whitewater_Beauty_v001.%04d.exr
31s002c002_Proxy_v001.%04d.exr
32s002c002_Utility_v001.%04d.exr
33s002c002_Utility_v001.%04d.exr
34s002c002_Vehicles_Beauty_v001.%04d.exr
35s002c002_Vehicles_PanelOnly_v001.%04d.exr
36s002c002_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!

Social
GitHubGitHub
© 2024 Huey Yeng
Back to Top
Dark BackgroundDefault Background