Make all files extension lower by a given directory name

Tiefeng Wu icebergwtf at
Wed Nov 1 11:35:19 CET 2006

Hello everybody!
I need make all files extension to lower by a given directory.
Here is my solution:

import os

def make_all_file_ext_lower(root):
    for path, subdirs, files in os.walk(root):
        for file in files:
            (name, ext) = os.path.splitext(file)
            fullname = name[:len(name) - 1] + ext.lower()
            os.rename(os.path.join(path, file), os.path.join(path, fullname))

I know this code is lame and maybe someone can give a better?
Just for learning, thanks! :)



More information about the Python-list mailing list