import os import fnmatch def find_pattern_all(pattern, path, casesensitive): result = [] for root, dirs, files in os.walk(path): for name in files: if sensitive: if fnmatch.fnmatchcase(name,pattern): result.append(os.path.join(root, name)) else: if fnmatch.fnmatch(name.lower(), pattern.lower()): result.append(os.path.join(root, name)) return result def find_pattern(pattern, path, casesensitive): for root, dirs, files in os.walk(path): for name in files: if sensitive: if fnmatch.fnmatchcase(name,pattern): return os.path.join(root, name) else: if fnmatch.fnmatch(name.lower(), pattern.lower()): return os.path.join(root, name) return None def find_all(name, path): result = [] for root, dirs, files in os.walk(path): if name in files: result.append(os.path.join(root, name)) return result def find(name, path): for root, dirs, files in os.walk(path): if name in files: return os.path.join(root, name) return None