python iterate directories code example
Example 1: python iterate through files in directory
import os
for filename in os.listdir(directory):
if filename.endswith(".asm") or filename.endswith(".py"):
# print(os.path.join(directory, filename))
continue
else:
continue
Example 2: python loop through files in directory recursively
import os
rootdir = './path/to/files/'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
print os.path.join(subdir, file)