# This program get's rid of all the files matching regex $regex (ckz_* in our case)
# temp files for user ARGV[0]
use File::Path;
my $user = $ARGV[0];
my $regex = $ARGV[1];
my $temp_dir = "C:\\Documents and Settings\\$user\\Local Settings\\Temp";
if (-d $temp_dir) {
opendir(DE,$temp_dir);}
my @all_files = readdir(DE);
foreach $file (@all_files) {
# Make sure file is not a directory
$entry = "$temp_dir\\$file";
if (-d $entry) {
if ($entry =~m/$regex/i) {
print "DELETING ENTRY: $entry\n";
rmtree($entry);
}
}
}
closedir(DE);
else {
print "Directory $temp_dir Does Not Exist!";
}
No comments:
Post a Comment