Skript, mis otsib üles duplikaatfailid - Python

From ICO wiki
Revision as of 12:23, 28 January 2011 by Csinihel (talk | contribs)
Jump to navigationJump to search

Midagi sellist

#!/usr/bin/python
# -*- coding: utf
import hashlib
import os 
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)