Problem with case insensitive volumes

dmoore damienlmoore at gmail.com
Mon May 4 23:24:40 EDT 2009


Does anyone know of a way to get the unique pathname for files stored
on FAT32 or other case insensitive drives?

For example:

os.path.samefile('/media/usbkey/file1.jpg','/media/usbkey/FILE1.jpg')

returns True

but, is there a simple way to determine whether '/media/usbkey/
file1.jpg' or '/media/usbkey/FILE1.jpg' is the actual representation
on the device.

it matters because operations like this have meaning:

os.rename('/media/usbkey/file1.jpg','/media/usbkey/tmp')
os.rename('/media/usbkey/tmp','/media/usbkey/FILE1.jpg')

If I have a program that scans a directory for files and compares
against a stored list of pathnames, I want to be able to determine not
only that the file still exists but whether or not it has changed case
(i.e. '/media/usbkey/file1.jpg' has become '/media/usbkey/FILE1.jpg').

Any takers?



More information about the Python-list mailing list