|
@@ -9,26 +9,20 @@ parser = argparse.ArgumentParser(description='What the dupe!?')
|
|
|
optional = parser._action_groups.pop() # Edited this line
|
|
|
required = parser.add_argument_group('required arguments')
|
|
|
|
|
|
-optional.add_argument('--size', type=str,
|
|
|
- help='Only output files greater than \'size\'. 16, 16K, 16M, 16G, 16T')
|
|
|
+optional.add_argument('--threshold', type=str,
|
|
|
+ help='Only output files greater than \'size\', e.g. 100M')
|
|
|
|
|
|
required.add_argument('--dir', type=str, nargs='?', required=True, action='append',
|
|
|
- help='Directory to scan. Can be used multiple times.')
|
|
|
+ help='Directory to scan. Can be issued multiple times.')
|
|
|
|
|
|
parser._action_groups.append(optional)
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
-max_size1='10M'
|
|
|
-max_size2='50M'
|
|
|
-max_size3='100M'
|
|
|
-max_size4='1G'
|
|
|
-max_size5='5G'
|
|
|
-max_size6='5G'
|
|
|
-sizes = [max_size1, max_size2, max_size3, max_size4, max_size5, max_size6]
|
|
|
+sizes = ['10M', '50M', '100M', '1G', '5G', 'gt5GB']
|
|
|
|
|
|
-if args.size:
|
|
|
- bytes = humanfriendly.parse_size(args.size)
|
|
|
+if args.threshold:
|
|
|
+ bytes = humanfriendly.parse_size(args.threshold)
|
|
|
else:
|
|
|
bytes = 0
|
|
|
|
|
@@ -74,7 +68,11 @@ def hashfile(path, blocksize = 65536):
|
|
|
|
|
|
|
|
|
def printResults(dict1):
|
|
|
- final = {max_size1:[], max_size2:[], max_size3:[], max_size4:[], max_size5:[], max_size6:[]}
|
|
|
+ final = {}
|
|
|
+ for size in sizes:
|
|
|
+ final[size] = []
|
|
|
+ del size
|
|
|
+ print(final)
|
|
|
if bytes > 0:
|
|
|
final[bytes] = []
|
|
|
results = list(filter(lambda x: len(x) > 1, dict1.values()))
|
|
@@ -85,24 +83,19 @@ def printResults(dict1):
|
|
|
final[bytes].append(result)
|
|
|
|
|
|
else:
|
|
|
- if file_size >= humanfriendly.parse_size(max_size1) and file_size < humanfriendly.parse_size(max_size2):
|
|
|
- final[max_size2].append(result)
|
|
|
- #print('1M-50M: '+result)
|
|
|
- elif file_size >= humanfriendly.parse_size(max_size2) and file_size < humanfriendly.parse_size(max_size3):
|
|
|
- final[max_size3].append(result)
|
|
|
- #print('50M-100M: '+result)
|
|
|
- elif file_size >= humanfriendly.parse_size(max_size3) and file_size < humanfriendly.parse_size(max_size4):
|
|
|
- #print('100M-1G: '+result)
|
|
|
- final[max_size4].append(result)
|
|
|
- elif file_size >= humanfriendly.parse_size(max_size4) and file_size < humanfriendly.parse_size(max_size5):
|
|
|
- #print('1G-5G: '+result)
|
|
|
- final[max_size5].append(result)
|
|
|
- elif file_size >= humanfriendly.parse_size(max_size5):
|
|
|
- #print('5G+: '+result)
|
|
|
- final[max_size6].append(result)
|
|
|
+ #0=10MB 1=50MB 2=100MB 3=1GB 4=5GB
|
|
|
+ if file_size >= humanfriendly.parse_size(sizes[0]) and file_size < humanfriendly.parse_size(sizes[1]):
|
|
|
+ final[sizes[1]].append(result)
|
|
|
+ elif file_size >= humanfriendly.parse_size(sizes[1]) and file_size < humanfriendly.parse_size(sizes[2]):
|
|
|
+ final[sizes[2]].append(result)
|
|
|
+ elif file_size >= humanfriendly.parse_size(sizes[2]) and file_size < humanfriendly.parse_size(sizes[3]):
|
|
|
+ final[sizes[3]].append(result)
|
|
|
+ elif file_size >= humanfriendly.parse_size(sizes[3]) and file_size < humanfriendly.parse_size(sizes[4]):
|
|
|
+ final[sizes[4]].append(result)
|
|
|
+ elif file_size >= humanfriendly.parse_size(sizes[4]):
|
|
|
+ final[sizes[5]].append(result)
|
|
|
else:
|
|
|
- #print('<1M: '+result)
|
|
|
- final[max_size1].append(result)
|
|
|
+ final[sizes[0]].append(result)
|
|
|
if len(results) > 0:
|
|
|
print('___________________')
|
|
|
print('\n\033[1;34m\033[1;34m\u25b6 Duplicates Found\033[0m\n')
|
|
@@ -120,7 +113,10 @@ def printResults(dict1):
|
|
|
for size in sizes:
|
|
|
new.append(size)
|
|
|
if len(final[size]) > 0:
|
|
|
- print("\n\033[1;34m\u25b6 Between %s and %s\033[0m" % (new[-2],size))
|
|
|
+ if size == 'gt5GB':
|
|
|
+ print("\n\033[1;34m\u25b6 >= %s\033[0m" % (new[-2]))
|
|
|
+ else:
|
|
|
+ print("\n\033[1;34m\u25b6 %s to %s\033[0m" % (new[-2],size))
|
|
|
for dupe in final[size]:
|
|
|
print('___________________\n')
|
|
|
for file in dupe:
|