Skip to content

Instantly share code, notes, and snippets.

@1oglop1
Created August 18, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1oglop1/10b8582a06caaaab404e05e3fa9f7a79 to your computer and use it in GitHub Desktop.
Save 1oglop1/10b8582a06caaaab404e05e3fa9f7a79 to your computer and use it in GitHub Desktop.
skill assesment
#!/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