[Tutor] renumbering a sequence

Paul McGuire ptmcg at austin.rr.com
Wed Aug 27 15:36:53 CEST 2008


One problem with my previous post.  I didn't look closely enough at the
original list of files, it turns out you have multiple entries for some of
them.  If you used the glob module to create this list (with something like
"original_list = glob.glob('frame.*.dpx')"), then there should be no problem
with duplicates.  But if the list was hand generated, you should probably
check for duplicates first.

The easiest way to do this is to use a Python set:

if len(set(original_names)) < len(original_names):
    print "Watch out! There are duplicate file names in the list!"

Of course, having duplicates in the original list makes no matter in the
generation of a new list of consecutively-numbered file names.  The problems
will arise when you go to actually do something with the generated list,
such as the renaming example I posted earlier.

-- Paul




More information about the Tutor mailing list