(Mar-05-2022, 05:14 AM)MaartenRo Wrote: I already learned some basic Python skills. I would like to learn python skills for searching through a lot of files. What should i focus on? Should i use books or a online course?For this should look into os module and pathlib(a more modern way).
To give example let say want to find a
.txt
file and that the search is recursively(all sub-folders) for this file.from pathlib import Path dest = r'C:\Test' for path in Path(dest).rglob('*.txt'): if path.is_file(): print(path)The same with os.walk.
import os dest = r'C:\Test' for root, dirs, files in os.walk(dest): for file in files: if '.txt' in file: print(os.path.join(root, file))I would say that looking most into pathlib(Taming the File System) is the way to go.
Also learn command line tools like find, grep, awk ...ect