rickgerdes
IS-IT--Management
I have a routine that seaches a directory tree for files that match the criteria - filename=8 numeric characters.*
Any eight numbers, doesn't matter. Wherever it finds these files, it needs to delete them. Currently I do this the very hard way of: (please don't laugh)
open(LIST, "dir t:\\tmwin\\????????.* /s/b/n |"
;
@all=<LIST>;
close LIST;
foreach $l (@all)
{
$l1 = substr $l, -13, 1;
$l2 = substr $l, -12, 1;
$l3 = substr $l, -11, 1;
$l4 = substr $l, -10, 1;
$l5 = substr $l, -9, 1;
$l6 = substr $l, -8, 1;
$l7 = substr $l, -7, 1;
$l8 = substr $l, -6, 1;
if ($l1 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l2 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l3 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l4 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l5 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l6 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l7 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l8 =~ /1|2|3|4|5|6|7|8|9|0/) {
system("del $l"
;
}
}
}
}
}
}
}
}
}
If there is a better way (there _has_ to be) can someone let me know?
Any eight numbers, doesn't matter. Wherever it finds these files, it needs to delete them. Currently I do this the very hard way of: (please don't laugh)
open(LIST, "dir t:\\tmwin\\????????.* /s/b/n |"
@all=<LIST>;
close LIST;
foreach $l (@all)
{
$l1 = substr $l, -13, 1;
$l2 = substr $l, -12, 1;
$l3 = substr $l, -11, 1;
$l4 = substr $l, -10, 1;
$l5 = substr $l, -9, 1;
$l6 = substr $l, -8, 1;
$l7 = substr $l, -7, 1;
$l8 = substr $l, -6, 1;
if ($l1 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l2 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l3 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l4 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l5 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l6 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l7 =~ /1|2|3|4|5|6|7|8|9|0/) {
if ($l8 =~ /1|2|3|4|5|6|7|8|9|0/) {
system("del $l"
}
}
}
}
}
}
}
}
}
If there is a better way (there _has_ to be) can someone let me know?