Reputation: 5816
I have a Python script and I want to check if a file exists, but I want to ignore case
eg.
path = '/Path/To/File.log'
if os.path.isfile(path):
return true
The directory may look like this "/path/TO/fILe.log". But the above should still return true.
Upvotes: 3
Views: 3066
Reputation: 362826
S
of all absolute paths in the filesystem using os.walk
, lowering them all as you collect them using str.lower
.if my_path.lower() in S
. Upvotes: 1