Re: Make all files extension lower by a given directory name

2006-11-03 Thread Martin Miller
Tim Chase wrote, in part: > ... > I've found that Win32 doesn't often take a rename if the origin > and destination differ only in case[*]. Thus, to change the > case, I've had to do *two* renames...one to, say, prefix with an > underscore and change the case to my desired case, and then one > to

Re: Make all files extension lower by a given directory name

2006-11-02 Thread Tiefeng Wu
Tim Chase wrote: > Having a win32 program take case-sensitive filenames is a bit > odd, given that the OS is case-agnostic...however, that doesn't > preclude bad programming on the part of your tool-maker. Alas. > > Thus, to accomodate the lousy programming of your tool's maker, I > proffer thi

Re: Make all files extension lower by a given directory name

2006-11-02 Thread Tim Chase
>> can you post an example of a filename that misbehaves on >> your machine? >> >> > > To Fredrik Lundh and Tim Chase: > > My task was read all tga file names and generate a config xml > file, then pass this xml file to a utility, but this utillity > only read files with extension 'tga' than 'T

Re: Make all files extension lower by a given directory name

2006-11-01 Thread Tiefeng Wu
Fredrik Lundh wrote: > that's not how splitext works, though: > > >>> os.path.splitext("FOO.BAR") > ('FOO', '.BAR') > > can you post an example of a filename that misbehaves on your machine? > > To Fredrik Lundh and Tim Chase: My task was read all tga file names and generate a config xml file, t

Re: Make all files extension lower by a given directory name

2006-11-01 Thread Tim Chase
>>> 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, f

Re: Make all files extension lower by a given directory name

2006-11-01 Thread Fredrik Lundh
Tiefeng Wu wrote: > strip off the last character because if simply add name > and ext I got result like "FOO..bar", there are two dots. that's not how splitext works, though: >>> os.path.splitext("FOO.BAR") ('FOO', '.BAR') can you post an example of a filename that misbehaves on your machine?

Re: Make all files extension lower by a given directory name

2006-11-01 Thread Tiefeng Wu
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

Re: Make all files extension lower by a given directory name

2006-11-01 Thread Fredrik Lundh
Tiefeng Wu wrote: > 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) the par

Make all files extension lower by a given directory name

2006-11-01 Thread 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[