Created
September 12, 2013 11:51
-
-
Save Ayrx/6536184 to your computer and use it in GitHub Desktop.
A code snippet to find the case sensitive version of path name on the system given a case insensitive version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def get_case_sensitive_pathname(path, top): | |
for root, dirs, files in os.walk(top): | |
for d in dirs: | |
if os.path.join(root, d).lower() == path.lower(): | |
return os.path.join(root, d) | |
for f in files: | |
if os.path.join(root, f).lower() == path.lower(): | |
return os.path.join(root, f) | |
return path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment