On Apr 3, 8:47 am, "gtb" <[EMAIL PROTECTED]> wrote: > On Apr 3, 8:31 am, [EMAIL PROTECTED] wrote: > > > > > On Apr 3, 8:21 am, "gtb" <[EMAIL PROTECTED]> wrote: > > > > I wish to copy the highest version number of a file from directory \ > > > \ > > > \fileserver\D:\scripts to C:\scripts where the file names are of the > > > form > > > > filename_MM.NN.SS.zip, where MM, NN, and SS can be one to three > > > digits. > > > > Example directory: > > > other.zip > > > dx_ver_1.1.63.zip > > > dx_ver_1.2.01.zip > > > dx_ver_1.12.7.zip > > > temp.txt > > > > Does python have string matching routines that would find the bottom > > > listed zip file and/or file copying routines? > > > > A little pointer or two would be much appreciated. > > > > Thanks, > > > > jh > > > You could just use string slicing to cut off the first 7 characters > > and have the numbers available to compare. There's also the os.stat > > module to find the last modified date of the file. You might be able > > to use the glob module to grab a list of the files and then sort the > > list too. > > > Mike > > Thanks for posting folks. I didn't make my question clear. Before I > sort the files I need to ensure that I am only sorting the files that > match the profile of "filename_MM.NN.SS.zip", where MM, NN, and SS can > be one to three > digits. > > Thanks again, > > jh
Then you probably need to use the glob module and the re module. You may even be able to just use the glob module by doing something like: filenames = glob.glob(r'pathtofiles\*.*.*.*.zip') and then sort that. Mike -- http://mail.python.org/mailman/listinfo/python-list