how can I make this script shorter?

Lowell Kirsh lkirsh at cs.ubc.ca
Tue Feb 22 03:34:39 EST 2005


I have a script which I use to find all duplicates of files within a 
given directory and all its subdirectories. It seems like it's longer 
than it needs to be but I can't figure out how to shorten it. Perhaps 
there are some python features or libraries I'm not taking advantage of.

The way it works is that it puts references to all the files in a 
dictionary with file size being the key. The dictionary can hold 
multiple values per key. Then it looks at each key and all the 
associated files (which are the same size). Then it uses filecmp to see 
if they are actually byte-for-byte copies.

It's not 100% complete but it's pretty close.

Lowell
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rem-dups.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20050222/f5c4329c/attachment.ksh>


More information about the Python-list mailing list