problem with addOnScriptSave

hey guys,
i have this few lines of code to copy a script to another location after it’s saved.


import nuke
import shutil

def myfunction():

      currScript = nuke.Root()['name'].value()
      backupPath = 'path/to/backup/folder/'

      shutil.copy(currScript, backupPath)

this is the entry in my


import myfunction

when i overwrite a script that already exists, this works like expected.
but when i try to save the script as a new script, i get an error message. this file doesn’t exist. so nothing is saved and nothing is copied.
i understand that ‘addOnScriptSave’ is executed before the script is saved. so this is an expected error.
i tried ‘nuke.scriptSave()’ before ‘shutil.copy(currScript, backupPath)’, but this gives me another error message: ‘maximum recursion depth exeeded‘.
would be great, if someone can point me to how i get the script saved before the copy command is executed!

thanks a lot,

No Responses to “problem with addOnScriptSave”

Post a Comment