All pastes #97063 Raw Edit

Someone

public python v1 · immutable
#97063 ·published 2006-07-23 10:46 UTC
rendered paste body
#!/usr/bin/pythonimport sysimport os# TIP: rm $(md5sum ./* | duplicate -) # that will remove all duplicate files in a directorydef main():   if len(sys.argv) != 2:      print("Usage: duplicate <md5sum output>");      return 0   file = sys.argv[1]   try:      if file == '-':         handle = sys.stdin      else:         handle = open(file)   except IOError:      os.write(2,"Couldn't open " + file + " for reading\n")      return(0)   filelist = []   md5list  = []   indexlist = []   line = handle.readline()   while line != '':      ls = line.split()      filelist.append(ls[1])      md5list.append(ls[0])      line = handle.readline()   handle.close()   for x in xrange(0,len(md5list)):      c = md5list.index(md5list[x])      indexlist.append ( (filelist[x],c) )   for x in xrange(0,len(indexlist)):      if x != indexlist[x][1]:         print(filelist[x])main()