File test Operator for Directory Age

From: RickB (rbryson992000_at_yahoo.com)
Date: 02/06/04


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!



Relevant Pages

  • Re: folders read only
    ... of folders in Windows Server 2003, in Windows XP, or in Windows ... You can change either attributes with VB Scripts. ... If you read beyond the "Summary" paragraph at the beginning, ...
    (microsoft.public.windowsxp.general)
  • Re: folders read only
    ... folders in Windows Server 2003, in Windows XP, or in Windows Vista" ... You can view the RO/S attributes in Windows Explorer. ... You can change either attributes with VB Scripts. ...
    (microsoft.public.windowsxp.general)
  • Remove File Encryption in Windows XP
    ... Is there a way to turn off a user's ability to encrypt files and/or folders ... in Windows ZP if he or she will not be using the feature? ...
    (microsoft.public.windows.file_system)
  • Re: new here, my lang project...
    ... needed in many cases (along with the ability to, say, call a constructor ... but, this is imo ugly, and is system dependent, and is a little short on ... > repair for scripts vs. C code, I'll bet you will find that proportional to ... typically this calls directly into the scripting language. ...
    (comp.object)
  • Re: GUI and Rapid Application Development?
    ... Most simple applications that I dealt with did not need the use of API ... I imagine Perl is faster, ... my Perl scripts are more compact ... Chirag> in Windows that could run on Windows 98 through 2003. ...
    (comp.os.linux.misc)