def onelevelok(parent, thislevel):
    for fn in os.listdir(parent):
        if fn.lower() == thislevel.lower():
            return fn == thislevel
raise ValueError('No %r in dir %r!' % (thislevel, parent))
Detecting case mismatch on filename in Windows (preferably using python)?