#!/usr/pkg/bin/perl # Author : Stefan Schumacher, , http://net-tex.de # PGP : 0xB3FBAE33 # Purpose : remove duplicate files # Created : Fri Mar 19 13:47:24 2004 # Version : $Header: /home/daten/cvs/net-tex.de/code/dblrem.pl.txt,v 1.1 2006/07/16 18:17:49 stefan Exp $ # Needs : md5(1) # released under BSD License, I will not support non-free forks # like Public Domain, closed source, GPL or other =man NAME dblrem.pl - remove duplicate files using a MD5 hash SYNOPSIS dblrem.pl DESCRIPTION dblrem.pl creates cryptographic MD5 hashes over filecontents and deletes duplicate files =cut my @allfiles = glob "*"; for my $file (@allfiles) { chomp($md5sum = `md5 $file`); $cksum = (split /= /,$md5sum)[1]; push (@hashedfiles, $file); $hash{"$cksum"} = "$file"; } while (my $key= each %hash) { push (@uniqfiles,$hash{$key}); } my $cmp=0; for my $element (@hashedfiles){ for my $qelement (@uniqfiles){ if ($element == $qelement){ $cmp++; } } if ($cmp < 1){ `rm -f $element \n`; } $cmp=0; }