Let's say I've got the following directory structure
PROJECT
|
+ BUILD
| |
| + STH1
| | |
| | + 6.11.2
| | |
| | + 6.11.3
| | |
| | + .....
| + STH2
| | |
| | + 6.11.2
| | |
| | + 6.11.3
| | |
| | + .....
+ COMMON
| |
| + 6.11.2
| |
| + ....
What would be the most efficient way to find all the 6.11.2 directories in the PROJECT directory in python?
I tried using
glob.glob('PROJECT/**/6.11.2', recursive=True)
It works, but it's not the best solution for me, because it will also look for directories like
PROJECT/BUILD/STH1/6.11.2/6.11.2
So it takes a lot of time, I only need to find the 1st occurrence of the directory 6.11.2, so searching deeper into it is a waste of time (also situation like sth/6.11.2/6.11.2 will not happen in my structure)
Is there a better way to do the search in python?
Note that 6.11.2 is also quite complex directory with lots of files and subdirectories, that's why it takes a lot of time to do the search recursively.