implement deletion feature
This commit is contained in:
parent
ccbf5a8acd
commit
c1372b7ed3
1 changed files with 9 additions and 3 deletions
|
|
@ -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,7 +172,12 @@ 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];
|
||||||
&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"; }
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue