Answers for "how to remove duplicate files from folder with python"

0

how to remove duplicate files from folder with python

def remove_duplicates(dir):
    unique = []
    for filename in os.listdir(dir):
        if os.path.isfile(filename):
            filehash = md5.md5(file(filename).read()).hexdigest()
            if filehash not in unique: 
                unique.append(filehash)
            else: 
                os.remove(filename)
Posted by: Guest on September-05-2021
0

how to remove duplicate files from folder with python

def remove_duplicates(dir):
    unique = []
    for filename in os.listdir(dir):
        if os.path.isfile(filename):
            filehash = md5.md5(file(filename).read()).hexdigest()
            if filehash not in unique: 
                unique.append(filehash)
            else: 
                os.remove(filename)
Posted by: Guest on September-05-2021

Code answers related to "how to remove duplicate files from folder with python"

Python Answers by Framework

Browse Popular Code Answers by Language