Make all files extension lower by a given directory name

T

Tiefeng Wu

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! :)

wutiefeng
06-11-01



___________________________________________________________
ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ
http://cn.mail.yahoo.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top