implement deletion feature

This commit is contained in:
Ward Wouts 2004-04-24 20:19:25 +00:00
parent ccbf5a8acd
commit c1372b7ed3

View file

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