Make all files extension lower by a given directory name

Tiefeng Wu icebergwtf at yahoo.com.cn
Wed Nov 1 09:16:48 EST 2006


Fredrik Lundh wrote:
> >             fullname = name[:len(name) - 1] + ext.lower()
> are you sure you want to strip off the last character in the actual 
> filename?  should "FOO.BAR" really be turned into "FO.bar" ?
> name[:len(name) - 1] can be written name[:-1], btw.
> >             os.rename(os.path.join(path, file), os.path.join(path, fullname))
> > 
> > I know this code is lame
> except for the potential bug, and possibly the lack of error handling 
> for the os.rename call, I'm not sure why you think that.
> </F>

thanks a lot!

strip off the last character because if simply add name and ext I got result like "FOO..bar", there are two dots.
I'm using python25, btw.

for the lack of error handling, because I'm a newbie and don't think about it at all :P

wutiefeng
2006-11-01


	

	
		
___________________________________________________________ 
Mp3疯狂搜-新歌热歌高速下
http://music.yahoo.com.cn/?source=mail_mailbox_footer



More information about the Python-list mailing list