File test Operator for Directory Age
From: RickB (rbryson992000_at_yahoo.com)
Date: 02/06/04
- Next message: rxl124_at_hehe.com: "Re: assigning contents to file name............"
- Previous message: Jürgen Exner: "Re: strange problem..program not working through web form."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 6 Feb 2004 11:34:39 -0800
Folks,
Sorry if this is too elemental. I am attempting to create some admin
scripts, among them the ability to delete folders older than X days.
Question: in the following code, what do I use to get the Age of a
Directory? I am using AcivePerl on Windows XP and Windows 2K.
use Win32;
use Win32::NetResource;
use Time::localtime;
# windows utility script for administration of disk space: delete old
# files/folders
$Name='C:\\Temp\\test';
if ( -d $Name )
{
# how to detect directory older than 2 weeks
print "Got a directory","\n";
}
else
{
if (-M $Name > 14)
{
# do good things for files older than 2 weeks
print "Got a file","\n";
}
}
exit 0;
Thank you in advance. I am new to Perl but am already a convert!
- Next message: rxl124_at_hehe.com: "Re: assigning contents to file name............"
- Previous message: Jürgen Exner: "Re: strange problem..program not working through web form."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|