Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: first row as column df 
Python :: python loop break on keypress 
Python :: pandas print full dataframe 
Python :: createview django 
Python :: remove duplicates from list python 
Python :: access-control-allow-origin django 
Python :: pyinstaller 
Python :: openpyxl add worksheet 
Python :: convert image to matrix python 
Python :: how to write to a file in python without deleting all content 
Python :: how to draw a bar graph in python 
Python :: how to get a row from a dataframe in python 
Python :: how to import data from csv to jupyter notebook 
Python :: python df round values 
Python :: python change a key in a dictionary 
Python :: python transform two columns to a list combine 
Python :: python check if type 
Python :: redirect to previous page django 
Python :: how to remove first letter of a string python 
Python :: download youtube-dl python 
Python :: how to get seconds from datetime in python 
Python :: how to save bulk create in django 
Python :: df drop based on condition 
Python :: python - removeempy space in a cell 
Python :: accessing dictionary elements in python 
Python :: logging in with selenium 
Python :: rotate array python 
Python :: delete files with same extensions 
Python :: is vowel python 
Python :: set image size mapltotlib pyplot 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =