I know that the file name is file001.txt
or FILE001.TXT
, but I don't know which. The file is located on a Windows machine that I'm accessing via samba mount point.
The functions in os.path
seem to be acting as though they were case-insensitive, but the open
function seems to be case-sensitive:
>>> from os.path import exists, isfile
>>> exists('FILE001.TXT')
True
>>> isfile('FILE001.TXT')
True
>>> open('FILE001.TXT')
Traceback (most recent call last):
File "<console>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'FILE001.TXT'
>>> open('file001.txt') # no problem
So, my questions are these:
Is there a way to determine what the file name is without opening the file (or listing the directory that it's in)?
Why is
open
case-sensitive whenos.path
isn't?
Update: thanks for the answers, but this isn't a python problem so I'm closing the question.