Last active
November 9, 2020 20:51
-
-
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.
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
# 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