I've been trying to figure out how I can loop through a root directory with sub directories and search for a file. If a specific file exists then run a script.
File structure example: Root --Folder 1 ----TEST.txt --Folder 2 ----[no files] --Folder 3 ----TEST.txt
What I am trying to achieve is having the .py file in Root. When run it will loop over each folder in Root, if the file TEST.txt then do some processing.
Notes: There will always be folders in Root Where processing is needed there will be a file called TEST.txt There will definitely be some folders that do not have TEST.txt
Pseudo code: From Root open Folder 1. If TEST.txt is there then do some cool stuff and then 'cd ../' and repeat process but look in Folder 2. Stop looping when all Folders have been checked.
os.walkandos.listdir: docs.python.org/3/library/os.html