TheTechGuy
Technical User
Hi there,
I have the following script which deletes all the *.pdf files in one folder older then 2 days, but I need something which would delete all the *.pdf files in all the sub-folders
#!/usr/bin/perl
STDERR
$dir = "c:/test/pdf" ;
opendir (DIR, "$dir/");
@FILES = grep(/.pdf/,readdir(DIR));
closedir (DIR);
foreach $FILES (@FILES) {
if (-M "$dir/$FILES" > 2) {
unlink("$dir/$FILES");
}
}
I have the following script which deletes all the *.pdf files in one folder older then 2 days, but I need something which would delete all the *.pdf files in all the sub-folders
#!/usr/bin/perl
STDERR
$dir = "c:/test/pdf" ;
opendir (DIR, "$dir/");
@FILES = grep(/.pdf/,readdir(DIR));
closedir (DIR);
foreach $FILES (@FILES) {
if (-M "$dir/$FILES" > 2) {
unlink("$dir/$FILES");
}
}