Changing file names

Larry Bates lbates at swamisoft.com
Wed May 26 19:15:45 EDT 2004


Sounds like you want to use os.path.walk function
which recursively drills down through directories and
subdirectories.  Then (as everyone else has pointed
out). You can use os.rename.

HTH,
Larry Bates
Syscon, Inc.

"Thomas Philips" <tkpmep at hotmail.com> wrote in message
news:b4a8ffb6.0405261213.33b823ce at posting.google.com...
> I want to get a list of all subdirectories of a given directory, and
> within each directory, change the name of each file using a
> predetermined rule.
>
> The function glob in module glob will give me a list of all the
> subdirectories, and by looping over this list and repeatedly calling
> glob, I can create lists of files within each directory, which are
> easily edited to create lists of new filenames.
>
> How then can I change the existing filenames to these new filenames?
> What python functions should I be using, and what modules are they
> contained in?
>
> Thomas Philips





More information about the Python-list mailing list