newer stuff forgot to commit
This commit is contained in:
parent
23e4c0e01b
commit
bd9ce1578e
1 changed files with 23 additions and 8 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# $Id$
|
||||
# $Source$
|
||||
|
||||
# Generates a list of files in cur. dir which are actually the same
|
||||
# Compares size and MD5 checksum
|
||||
# Handy for cleaning up pictures like this:
|
||||
|
|
@ -7,6 +10,8 @@
|
|||
|
||||
# wishlist:
|
||||
# - entering a list of file to check on the commandline
|
||||
# - include escapes in output (spaces, brackets, etc) (optional)
|
||||
# - option to ignore 0 length files
|
||||
|
||||
|
||||
# Changelog:
|
||||
|
|
@ -18,7 +23,10 @@
|
|||
# use MD5; instead of a shell call to md5
|
||||
# some cleaning of code
|
||||
|
||||
use MD5;
|
||||
use Digest::MD5;
|
||||
use Getopt::Std;
|
||||
|
||||
getopts('s');
|
||||
|
||||
opendir(DIR, ".") or die "can't open . $!";
|
||||
while (defined($file = readdir(DIR))) {
|
||||
|
|
@ -32,17 +40,24 @@ foreach (@filelist) {
|
|||
}
|
||||
}
|
||||
|
||||
foreach (keys %sizes) {
|
||||
if (@{$sizes{$_}} > 1) {
|
||||
foreach $size (keys %sizes) {
|
||||
if (@{$sizes{$size}} > 1) {
|
||||
%md5s = ();
|
||||
foreach (@{$sizes{$_}}) {
|
||||
foreach (@{$sizes{$size}}) {
|
||||
push @{$md5s{&calc_md5($_)}}, $_;
|
||||
}
|
||||
foreach (keys %md5s) {
|
||||
if (@{$md5s{$_}} > 1) {
|
||||
foreach (@{$md5s{$_}}) { print "$_ "; }
|
||||
foreach $key (keys %md5s) {
|
||||
if ((@{$md5s{$key}} > 1) and !$opt_s ) {
|
||||
foreach (@{$md5s{$key}}) { print "$_ "; }
|
||||
print "\n";
|
||||
}
|
||||
elsif ((@{$md5s{$key}} > 1) and $opt_s ) {
|
||||
@files = sort @{$md5s{$key}};
|
||||
for $i (1 .. $#files) {
|
||||
chomp $files[$i];
|
||||
print "$files[$i]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +76,7 @@ sub get_size {
|
|||
sub calc_md5($file) {
|
||||
my ($file, $digest);
|
||||
$file = shift;
|
||||
$md5 = new MD5;
|
||||
$md5 = Digest::MD5->new;
|
||||
open FILE, "<$file" or die "couldn't open file: $!\n";
|
||||
seek(FILE, 0, 0);
|
||||
$md5->reset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue