diff --git a/list_same/list_same b/list_same/list_same index 1400afe..88b897e 100755 --- a/list_same/list_same +++ b/list_same/list_same @@ -33,7 +33,7 @@ if ( $opts{m} ) { # functions sub cmdline { - getopts('ehms', \%opts); + getopts('dehms', \%opts); if ( $opts{h} ) { &help; } map { if ( -d $_ ) { s/\/$//; push @dirs, $_; } else { die "$_ not a directory" } } @ARGV; @@ -172,7 +172,12 @@ sub output_doubles(@) { @files = sort dirsort @{$md5s{$key}}; for $i ($start .. $#files) { chomp $files[$i]; - &output("$files[$i]\n"); + if ($opts{d}) { + print "Deleting: $files[$i]\n"; + unlink($files[$i]) or die "Couldn't unlink $files[$i]"; + } else { + &output("$files[$i]\n"); + } } unless($opts{s}) { print "\n"; } } @@ -186,7 +191,7 @@ sub output($) { $string = &escape($string); } print "$string"; -} +} sub escape($) { my $string = shift; @@ -241,6 +246,7 @@ sub help { Usage: $name [OPTION] ... + -d delete resulting files -e escape output filenames with backslashes -h display this help message -m mp3 compare, ignores ID3 tags (slow)