Last active
September 10, 2020 19:12
-
-
Save tokejepsen/a5fb683aafedf5a3d176f2a52ef5111a to your computer and use it in GitHub Desktop.
Nuke Recursive Read
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import clique | |
def recursive_read(): | |
path = nuke.getClipname("Choose Folder", multiple=False) | |
collection_names = {} | |
for root, dirs, files in os.walk(path): | |
files = [os.path.join(root, x).replace("\\", "/") for x in files] | |
collections, remainder = clique.assemble(files) | |
for collection in collections: | |
file = collection.format("{head}{padding}{tail}") | |
collection_names[file] = collection | |
for key in sorted(collection_names.keys()): | |
collection = collection_names[key] | |
read_name = os.path.basename(list(collection)[0]).replace(" ", "_") | |
file = collection.format("{head}{padding}{tail}") | |
first = list(collection.indexes)[0] | |
last = list(collection.indexes)[-1] | |
read_node = nuke.createNode( | |
"Read", | |
"name {}".format(read_name), | |
inpanel=False | |
) | |
read_node["file"].fromUserText(file) | |
read_node["origfirst"].setValue(first) | |
read_node["first"].setValue(first) | |
read_node["origlast"].setValue(last) | |
read_node["last"].setValue(last) | |
recursive_read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment