Skip to content

Instantly share code, notes, and snippets.

@kpprt
Last active August 23, 2017 15:19
Show Gist options
  • Save kpprt/ea552d3de59450cea61d055622da6103 to your computer and use it in GitHub Desktop.
Save kpprt/ea552d3de59450cea61d055622da6103 to your computer and use it in GitHub Desktop.
Calling this script in Nuke opens all file paths in the Explorer/Finder within the current selection of enabled nodes. It can also recurse into enabled groups and apply a filter that only opens paths from specific types of nodes, e.g. Read or Write.
import os
import platform
import subprocess
def open_file_folders(nodes, filter = None, recurseGroups = True):
for n in nodes:
if n.knob('disable') and n['disable'].value() == True:
#print 'skipping {0} because it is disabled'.format(n['name'].value())
continue
if recurseGroups and isinstance(n, nuke.Group):
#print 'recursing into {0}'.format(n['name'].value())
open_file_folders(n.nodes(), filter, recurseGroups)
if filter != None and n.Class() != filter:
#print 'skipping {0} because it is not of type {1}'.format(n['name'].value(), filter)
continue
if n.knob('file'):
path = n['file'].evaluate()
if path != None and path != '':
print '{0}: {1}'.format(n['name'].value(), path)
folder = os.path.dirname(os.path.abspath(path))
if os.path.exists(folder):
if platform.system() == 'Windows':
subprocess.Popen('explorer "{0}"'.format(folder))
elif platform.system() == 'Darwin':
subprocess.Popen(["open", path])
elif platform.system() == 'Linux':
subprocess.Popen(["xdg-open", path])
open_file_folders(nuke.selectedNodes(), 'Write')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment