retDirs, retFiles = [], []
for root, dirs, files in os.walk(dirname):
    for i in dirs:
        retDirs.append(os.path.join(root, i))
for i in files:
    if suffixPattern is None or suffixPattern.search(i) is not None:
        retFiles.append((root, i))
return retDirs, retFiles
How to loop through files and rename them in Python