Here is a snippet of code which reads a directory and tests for file older
than x:
#!perl -w
my $WorkLoc = 'Directory name here';
opendir(DIR,"$WorkLoc") || die "Unable to open directory $WorkLoc for
read:$!";
while ( 1 ) {
my $filename = readdir(DIR);
last if ( ! defined $filename ); # done reading the directory
next if ( $filename =~ /^\./ or -d $filename ); # if . or .. or a
directory
my $LastMod = -M $filename; # number of days since it was modified
next if ( $LastMod < 5 ); # replace 5 with the number of days to check
against
printf "%-20s %5d\n", $filename, $LastMod; # print info vs delete
}
closedir(DIR);
Wags ;) ps this is for win2k, using AS 5.6.0 but should work for any perl
setup.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Monday, May 21, 2001 11:38
To: [EMAIL PROTECTED]
Subject: Time stamp ?
All,
I want to remove files which are older than 2 days. Is there any easy
way
to do that perl (high level syntax, please) ? or do I 've to get the date
from
the time stamp of the file and compare with current date to remove them. In
UNIX
I use mtime with find command.
I would appreciate any help.
Thx
Kailash