File test Operator for Directory Age

R

RickB

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top