Last active
December 17, 2015 06:28
-
-
Save bshillingford/5565243 to your computer and use it in GitHub Desktop.
Duplicate finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
import subprocess | |
from collections import defaultdict | |
from glob import glob | |
import sys | |
pattern = sys.argv[1] | |
d = defaultdict(lambda: []) | |
filenames = subprocess.check_output("find . -type f -name '{}' -print0 2>/dev/null; exit 0".format(pattern), shell=True).split('\0') | |
for filename in filenames: | |
if len(filename) == 0: | |
continue | |
md5 = subprocess.check_output(["md5sum", filename]).split()[0] | |
d[md5].append(filename) | |
print "Groups below (grouped by =======) are exact dupl." | |
for key in d.keys(): | |
if len(d[key]) >= 2: | |
print '====================================' | |
for value in d[key]: | |
print value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment