勉強ついでに5000件程度のファイルのサイズをチェックして重複を削除するプログラムを作ったのですが時間がかかりすぎて不便を感じてます。
より高速に処理するにはどう記述したら良いでしょうか?
i = 0
path = '/hoge/'
files = os.listdir(path)
del_list = []
while i < len(files):
File = path + files[i]
j = i + 1
while j < len(files):
File_check = path + files[j]
if os.path.getsize(File) == os.path.getsize(File_check):
del_list.append(File_check)
j = j + 1
for del_file in del_list:
os.remove(del_file)