Hi I have some code which works nine times out of ten. Maybe some could help me make this a little more robust. I have a bunch of files in a folder with a strict versioning based naming convention, where I want to open the highest version number of a nuke script (not necessarily the one with the newest modification date). So in the example folder contents listed below I want to open "233_bb0072_comp_comp2k_v05.nk" (fourth from the bottom). Every once in a while my python script ends up opening 233_bb0072_comp_comp2k_v04.nk (the next to last correct one). The script I am using is shown below. Can anyone explain why it doesn't always work?
233_bb0072_comp_comp2k_v01.nk 233_bb0072_comp_comp2k_v01.nk~ 233_bb0072_comp_comp2k_v02.nk 233_bb0072_comp_comp2k_v03.nk 233_bb0072_comp_comp2k_v03.nk~ 233_bb0072_comp_comp2k_v04.nk 233_bb0072_comp_comp2k_v04.nk~ 233_bb0072_comp_comp2k_v05.nk 233_bb0072_comp_comp2k_v05.autosave 233_bb0072_comp_comp2k_v05.nk~ 233_bb0072_comp_comp2k_v06.nk ####################################### import os def openNewestCompCommandLine(): theDirectory = "/path/to/my/comps/" theFilesInTheFolder = os.listdir(theDirectory) for aFile in theFilesInTheFolder: if "~" not in aFile: if "autosave" not in aFile: theNukeFileName = aFile theFullPath = theDirectory + theNukeFileName os.system("nuke " + theFullPath) if __name__ == '__main__': openNewestCompCommandLine() for aFile in theFilesInTheFolder: print aFile ################################################ Pete
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor