Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # change based on OS
  2.  
  3. import platform
  4.  
  5. # creates user system variables
  6. varRoot_Win = nuke.getInput('Windows File Root', 'E:/')
  7. varRoot_Lin = nuke.getInput('Linux File Root', '/media/Waterfall/')
  8.  
  9. # make sure that the file paths end in a backslash (/)
  10. if varRoot_Win[ len(varRoot_Win) - 1 ] != '/':
  11.     varRoot_Win += '/'
  12. if varRoot_Lin[ len(varRoot_Lin) - 1 ] != '/':
  13.     varRoot_Lin += '/'
  14.  
  15. # create a list of all of only the Read nodes in the Nuke script
  16. a = nuke.allNodes('Read')
  17.  
  18. if (platform.system() == 'Windows') or (platform.system() == 'Microsoft'):
  19.     print 'OS = Windows'
  20. else:
  21.     print 'OS = Linux'
  22.  
  23. i = 0
  24. for n in a:
  25.     # set the working node from the list of nodes based on it's name
  26.     b = nuke.toNode(a[i].name())
  27.    
  28.     # get the file path for the current node
  29.     c = b['file'].getValue()
  30.  
  31.     # query the OS and change the file path appropiately
  32.     if (platform.system() == 'Windows') or (platform.system() == 'Microsoft'):
  33.         d = c.replace(varRoot_Lin, varRoot_Win)
  34.     else:
  35.         d = c.replace(varRoot_Win, varRoot_Lin)
  36.  
  37.     # replace the file path with the new file path
  38.     b['file'].setValue(d)
  39.  
  40.     i += 1