|
-
Download Active Perl (for NT) from perl.com and write a simple script.
Here is a sample script I use. I learned a little bit of Perl just for this script purposes so this may not be the best script --
opendir(dirname, "d:/archive2/");
$count = 0;
$age = 0;
#---------------------------------------------------------------------
# Read one file at a time and delete if it is older than specified days
#---------------------------------------------------------------------
while ($file = readdir(dirname))
{
#-------------------------------------------------------------
# Prefix the file name with the directory Path otherwise
# it will not delete
#-------------------------------------------------------------
$file = "d:/archive2/" . $file;
$age = -M $file;
print "$file is $age days old\n";
#-------------------------------------------------------------
# Check if the file is at least 7 days old
#-------------------------------------------------------------
if ($age > 7)
{
#-----------------------------------------------------
# Delete the file
#-----------------------------------------------------
unlink($file);
print "Deleted file : $file\n";
$count = $count +1;
}
}
closedir dirname;
print "Total $count files were deleted. \n";
Rajeev Suri
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|