Mathieu Comandon on Nostr: So many tools to find duplicates on Linux. None of them do import os import sys def ...
So many tools to find duplicates on Linux. None of them do
import os
import sys
def list_dir(path):
res = {}
for root, _, files in os.walk(path):
for file in files:
res[(file, os.stat(os.path.join(root, file)).st_size)] = root
return res
source = list_dir(sys.argv[1])
copy = list_dir(sys.argv[2])
for dupe in set(source.keys()).intersection(set(copy.keys())):
path = copy[dupe]
os.unlink(os.path.join(path, dupe[0]))
import os
import sys
def list_dir(path):
res = {}
for root, _, files in os.walk(path):
for file in files:
res[(file, os.stat(os.path.join(root, file)).st_size)] = root
return res
source = list_dir(sys.argv[1])
copy = list_dir(sys.argv[2])
for dupe in set(source.keys()).intersection(set(copy.keys())):
path = copy[dupe]
os.unlink(os.path.join(path, dupe[0]))