Make all files extension lower by a given directory name

Martin Miller ggrp1.20.martineau at dfgh.net
Fri Nov 3 16:35:55 EST 2006


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 strip off the leading underscore.  You might try a similar
> song-and-dance to strong-arm Windows into specifying the case of
> the file.  ...

FWIW, I just tried a file name case-only os.rename() on a file running
Win XP SP2 with Python 2.5 and it worked just fine -- i.e. changed
'TextFile.TXT' to 'TextFile.txt') with just a single call to
os.rename(), no error was raised, and the case of the letters in the
file name were changed properly. (I can also do the same thing at the
command line with a similar results.)

Perhaps you were using a different version of Windows or the os module
(silently) handles the situation. I do agree that this is arguably
strange behavior given how the OS mostly ignores case...

-mm




More information about the Python-list mailing list