This script can be used to find files
in a windows directory older than 40 min. List can be emailed to a
user also.
Script can be modified to find files
older than whatever timeframe is needed.
use File::Find;
$receiver = "team@gmail.com";
$message = "Files waiting for more than 40 minutes in E:/cd/sci/Prod/outbound directory
";
$sendmail = "no";
use NTsendmail;
opendir(MYDIR, "E:/cd/sci/Prod/outbound") or die ("Cannot open dir to read");
chdir("E:/cd/sci/Prod/outbound");
@name = readdir(MYDIR);
foreach $x (@name) {
if ( -s $x and -M $x > 0.028 ) {
$write_secs = (stat($x))[9];
$sendmail = "yes";
$message .= sprintf " %s updated on %s
", $x,scalar localtime($write_secs);
}
}
closedir DIR;
#print $message;
if ( $sendmail eq "yes" ) {
$ENV{"NTsendmail"} = "smtp.language-tutorial.com";
$mail = new NTsendmail;
$sender = "admin@language-tutorial.com";
$subject = "File Alert";
$mail->send($sender, $receiver, $subject, $message);
}
# end of script

