|
@@ -7,11 +7,12 @@ parser = argparse.ArgumentParser(description='What the dupe!?')
|
|
|
|
|
|
optional = parser._action_groups.pop()
|
|
|
required = parser.add_argument_group('required arguments')
|
|
|
+exclusive= parser.add_mutually_exclusive_group(required=False)
|
|
|
|
|
|
-optional.add_argument('--threshold', type=str,
|
|
|
+exclusive.add_argument('--threshold', type=str,
|
|
|
help='Only output files greater than \'size\', e.g. 100M')
|
|
|
|
|
|
-optional.add_argument('--sizes', type=str, nargs='+',
|
|
|
+exclusive.add_argument('--sizes', type=str, nargs='+',
|
|
|
help='Only output files greater than \'size\', e.g. 100M')
|
|
|
|
|
|
required.add_argument('--dir', type=str, nargs='?', required=True, action='append',
|
|
@@ -42,10 +43,12 @@ else:
|
|
|
def findDup(parentFolder):
|
|
|
# Dups in format {hash:[names]}
|
|
|
dups = {}
|
|
|
+ print()
|
|
|
for dirName, subdirs, fileList in os.walk(parentFolder):
|
|
|
# remove excluded dirs from list
|
|
|
- for exclude in args.exclude:
|
|
|
- subdirs[:] = [dn for dn in subdirs if dirName+'/'+dn != exclude]
|
|
|
+ if args.exclude:
|
|
|
+ for exclude in args.exclude:
|
|
|
+ subdirs[:] = [dn for dn in subdirs if dirName+'/'+dn != exclude]
|
|
|
print(' Scanning %s...' % dirName)
|
|
|
for filename in fileList:
|
|
|
# Get the path to the file
|
|
@@ -110,14 +113,13 @@ def printResults(dict1):
|
|
|
if args.threshold and args.sizes:
|
|
|
pass
|
|
|
elif file_size < humanfriendly.parse_size(sizes[0]):
|
|
|
- print('Hi')
|
|
|
final[sizes[0]].append(result)
|
|
|
else:
|
|
|
- print('Hi')
|
|
|
if file_size >= threshold:
|
|
|
final[threshold].append(result)
|
|
|
|
|
|
- if len(results) > 0:
|
|
|
+ status=[x for x in final if len(final[x]) > 0]
|
|
|
+ if len(results) > 0 and (len(status) > 0):
|
|
|
print('___________________')
|
|
|
print('\n\033[1;34m\033[1;34m\u25b6 Duplicates Found\033[0m\n')
|
|
|
print(' The following files are identical. The name could differ, but the content is identical')
|