import os

def getcase(filepath):
    path, filename = os.path.split(filepath)
for fname in os.listdir(path):
    if filename.lower() == fname.lower():
        return os.path.join(path, fname)
print(getcase('/usr/myfile.txt'))
In python on OSX with HFS+ how can I get the correct case of an existing filename?