Changing file names

Fredrik Lundh fredrik at pythonware.com
Wed May 26 16:25:40 EDT 2004


Thomas Philips wrote:

> 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?

os.rename(oldname, newname)

found under "files and directories" in the library reference:

    http://docs.python.org/lib/os-file-dir.html

</F>







More information about the Python-list mailing list