duplicate finder python modules

Solutions on MaxInterview for duplicate finder python modules by the best coders in the world

showing results for - "duplicate finder python modules"
Domenico
07 Mar 2018
1def findDup(parentFolder):
2    # Dups in format {hash:[names]}
3    dups = {}
4    for dirName, subdirs, fileList in os.walk(parentFolder):
5        print('Scanning %s...' % dirName)
6        for filename in fileList:
7            # Get the path to the file
8            path = os.path.join(dirName, filename)
9            # Calculate hash
10            file_hash = hashfile(path)
11            # Add or append the file path
12            if file_hash in dups:
13                dups[file_hash].append(path)
14            else:
15                dups[file_hash] = [path]
16    return dups
17