1import os
2directory = 'the/directory/you/want/to/use'
3
4for filename in os.listdir(directory):
5 if filename.endswith(".txt"):
6 #do smth
7 continue
8 else:
9 continue
1import os
2
3for filename in os.listdir(directory):
4 if filename.endswith(".asm") or filename.endswith(".py"):
5 # print(os.path.join(directory, filename))
6 continue
7 else:
8 continue
1import os
2
3for filename in os.listdir(directory):
4 if filename.endswith(".asm") or filename.endswith(".py"):
5 # print(os.path.join(directory, filename))
6 continue
7 else:
8 continue
9
1basepath = "pathtodir/DataFiles/"
2for filename in os.listdir(basepath):
3 if filename.endswith(".log"):
4 print(os.path.join("./DataFiles", filename))
5
6 with open(basepath + filename) as openfile:
7 for line in openfile:
8 ........