So, I have the following application...
I have a folder with more than ten thousand folders on it. Each folder is a job and all of them have the same format:
"ten digits" + _ + "the name of the job"
Like this:
"1234567890_Stackoverflow"
How can I find the full name of that folder with just the first 10 digits?
This is my Python code:
Where path
is my current working directory and job
is my ten digits I want to find
for dirs in os.listdir(path):
if fnmatch.fnmatch(dirs, job+"*"):
job_name = dirs
break
job_path=path+'\\'+job_name
print(job_path)
With this code, I can find the full name of the job, but no matter which job I am asking for it always takes 23 seconds to find it.
Is there a faster way to find it?
I mean, if I manually go the job's folders, I can search the folder in 4-5 seconds, but manually.