I'm am trying to through files in a directory and find duplicates and delete them. I have 29 000 files in the directory so doing a brute force will take more than a day.
I have filenames that are as follow:
"some_file_name" "some-file-name"
So one name has underscores and the other one has dashes and sometimes they are 2 or three spots apart.
So how do I have my inner loop start at the outer loop's position in the directory and make it check only the next 10?
Here is my brute force code:
import glob, os
os.chdir("C:/Dir/dir")
for file in glob.glob("*"):
temp = file
temp = temp.replace("-", " ")
temp = temp.replace("_", " ")
#How do I start this loop where file is currently at and continue for the next 10 files
for file2 in glob.glob("*"):
temp2 = file2
temp2 = temp2.replace("-", " ")
temp2 = temp2.replace("_", " ")
if temp == temp2:
os.remove(file2)