|
@@ -43,24 +43,23 @@ else:
|
|
|
def findDup(parentFolder):
|
|
|
# Dups in format {hash:[names]}
|
|
|
dups = {}
|
|
|
- print()
|
|
|
for dirName, subdirs, fileList in os.walk(parentFolder):
|
|
|
- if args.exclude and dirName in args.exclude:
|
|
|
- continue
|
|
|
- else:
|
|
|
- print(' Scanning %s...' % dirName)
|
|
|
- for filename in fileList:
|
|
|
- # Get the path to the file
|
|
|
- path = os.path.join(dirName, filename)
|
|
|
+ # remove excluded dirs from list
|
|
|
+ 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
|
|
|
+ path = os.path.join(dirName, filename)
|
|
|
+ # Calculate hash
|
|
|
+ if os.path.exists(path):
|
|
|
# Calculate hash
|
|
|
- if os.path.exists(path):
|
|
|
- # Calculate hash
|
|
|
- file_hash = hashfile(path)
|
|
|
- # Add or append the file path
|
|
|
- if file_hash in dups:
|
|
|
- dups[file_hash].append(path)
|
|
|
- else:
|
|
|
- dups[file_hash] = [path]
|
|
|
+ file_hash = hashfile(path)
|
|
|
+ # Add or append the file path
|
|
|
+ if file_hash in dups:
|
|
|
+ dups[file_hash].append(path)
|
|
|
+ else:
|
|
|
+ dups[file_hash] = [path]
|
|
|
return dups
|
|
|
|
|
|
|