I need to iterate through all .asm
files inside a given directory and do some actions on them.
How can this be done in a efficient way?
I really like using the scandir
directive that is built into the os
library. Here is a working example:
import os
i = 0
with os.scandir('/usr/local/bin') as root_dir:
for path in root_dir:
if path.is_file():
i += 1
print(f"Full path is: {path} and just the name is: {path.name}")
print(f"{i} files scanned successfully.")