I have a folder that contains a few files of different types (.cpp, .hpp, .ipp ...) and in that folder are multiple sub-folders that also contain these different file types. My question is, is there a single loop that I can make that will search the first main folder and return a list full of all the .cpp files from either folder? So far, I know that:
folder_list = [f for f in os.listdir(os.getcwd()) if os.path.isdir(f)]
will return a list of the sub-folders, and then I can change the working directory and get the files list to append.
I also know that:
file_list = [f for f in listdir(os.getcwd()) if isfile(join(os.getcwd(), f))]
will return a list of the files.
However, I won't know the names of these sub-folders (and therefore the directory) beforehand. Thank you for any help