Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # change based on old/new vlaues
  2.  
  3. import platform
  4.  
  5. # creates user system variables
  6. varRoot_old = nuke.getInput('Old File Root', 'E:/')
  7. varRoot_new = nuke.getInput('New File Root', 'E:/someotherfolder/')
  8.  
  9. # make sure that the file paths end in a backslash (/)
  10. if varRoot_old[ len(varRoot_old) - 1 ] != '/':
  11.     varRoot_old += '/'
  12. if varRoot_new[ len(varRoot_new) - 1 ] != '/':
  13.     varRoot_new += '/'
  14.  
  15. # create a list of all of only the Read nodes in the Nuke script
  16. a = nuke.allNodes('Read')
  17.  
  18. i = 0
  19. for n in a:
  20.     # set the working node from the list of nodes based on it's name
  21.     b = nuke.toNode(a[i].name())
  22.    
  23.     # get the file path for the current node
  24.     c = b['file'].getValue()
  25.  
  26.     # change from the old root path to the new root path
  27.     d = c.replace(varRoot_old, varRoot_new)
  28.  
  29.     # replace the file path with the new file path
  30.     b['file'].setValue(d)
  31.  
  32.     i += 1