I have a multiple directory and each has files in thousands(10k+).. Lets pick one directory A
having 10k files . I have some another directory(say it as B
) that has files in thousands. I'm trying to find all files that appear in both A
and B
and also have a particular file extension (let's say .docx
). I can apply a nested for loop easily, but as the files are in many thousands, it takes lot of time. Is there any faster way in python to perform it? Any specific algo you want to suggest or any snippet code ?
Note - I know how to search and get files in multiple ways, I am asking suggestion for the fastest approach, files are in millions and iterating through each again and again will cost resource..