A
Alitaia
I write a simple perl, del.pl, to use File::Find to find *.ape and
delete them. I can find the *.ape but can not del outside the
directory, can del them within the directory, I dont know what's
wrong.
for example:
If directory structure like this:
---./layer1
|
/layer2
|
a.ape
b.ape
with the following code, within layer2
#del.pl ./ a.ape and b.ape can be deleted
but if under ./layer1,
#del.pl ./layer2 a.ape, b.ape can be found but can not del
what is wrong?
#!/usr/bin/perl -w
#name: del.pl
use strict;
use File::Find;
sub wanted {
$_ = $File::Find::name;
if ( /\.ape$/ ) {
my $file = $File::Find::name;
print "Found ape file: $file\n";
#system "shntool", "conv", "-o", "flac", $File::Find::name;
my $cnt = unlink $file;
print "\$cnt is $cnt\n";
}
}
my $dir = shift;
$dir ||=".";
find (\&wanted, $dir);
delete them. I can find the *.ape but can not del outside the
directory, can del them within the directory, I dont know what's
wrong.
for example:
If directory structure like this:
---./layer1
|
/layer2
|
a.ape
b.ape
with the following code, within layer2
#del.pl ./ a.ape and b.ape can be deleted
but if under ./layer1,
#del.pl ./layer2 a.ape, b.ape can be found but can not del
what is wrong?
#!/usr/bin/perl -w
#name: del.pl
use strict;
use File::Find;
sub wanted {
$_ = $File::Find::name;
if ( /\.ape$/ ) {
my $file = $File::Find::name;
print "Found ape file: $file\n";
#system "shntool", "conv", "-o", "flac", $File::Find::name;
my $cnt = unlink $file;
print "\$cnt is $cnt\n";
}
}
my $dir = shift;
$dir ||=".";
find (\&wanted, $dir);