Skip to content

Instantly share code, notes, and snippets.

@cedricduriau
Last active November 9, 2020 20:51
Show Gist options
  • Save cedricduriau/8074438637d6bafae2ecd74632671b44 to your computer and use it in GitHub Desktop.
Save cedricduriau/8074438637d6bafae2ecd74632671b44 to your computer and use it in GitHub Desktop.
Fusion Comp Script, renames all loader and saver nodes inside the active comp with the filename, without extension, of their Clip.
# stdlib module
import os
if __name__ == "__main__":
# get all loaders in current comp
loaders = comp.GetToolList(False, "Loader").values()
savers = comp.GetToolList(False, "Saver").values()
nodes = []
nodes.extend(loaders)
nodes.extend(savers)
for node in nodes:
old_name = node.Name
# get clip from node
clip = node.Clip[0]
# skip nodes with an empty clip
if not clip:
continue
# build new node name from clip
filename = os.path.basename(node.Clip[0])
new_name = os.path.splitext(filename)[0]
# only update node name when current name is different from new name
if old_name != new_name:
node.SetAttrs({"TOOLS_Name": new_name, "TOOLB_NameSet": 1})
print("renamed {} {!r} to {!r}".format(node.ID, old_name, new_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment