Created
August 18, 2016 12:36
-
-
Save 1oglop1/10b8582a06caaaab404e05e3fa9f7a79 to your computer and use it in GitHub Desktop.
skill assesment
This file contains hidden or 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/python3 | |
import filecmp as fcmp | |
import itertools as it | |
from pprint import pprint | |
import sys | |
import os | |
if 2 != len(sys.argv): | |
print("Usage: dup.py [FOLDER]") | |
exit() | |
else: | |
w_dir = sys.argv[1] | |
lof = os.listdir(w_dir) | |
lof = [os.path.join(w_dir,file) for file in lof] | |
dups =dict() | |
scanned=[] | |
not_scanned=[x for x in range(len(lof))] | |
while(not_scanned): | |
id1 = not_scanned.pop(0) | |
f1 = lof[id1] | |
for id2 in not_scanned: | |
if id2 in scanned: | |
continue | |
f2 = lof[id2] | |
if fcmp.cmp(f1, f2, shallow=True): | |
scanned.append(id2) | |
not_scanned.remove(id2) | |
try: | |
dups[f1].append(os.path.basename(f2)) | |
except: | |
dups[f1]=[os.path.basename(f2)] | |
pprint(dups) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment