Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How do we find the age of a directory ??

by prasadbabu (Prior)
on Nov 01, 2007 at 05:25 UTC ( [id://648433]=note: print w/replies, xml ) Need Help??


in reply to How do we find the age of a directory ??

dilip_val,

Yes, you can use '-d', which checks for the directory.

Take a look at "-X FILEHANDLE" in perlfunc

Prasad

  • Comment on Re: How do we find the age of a directory ??

Replies are listed 'Best First'.
Re^2: How do we find the age of a directory ??
by dilip_val (Acolyte) on Nov 06, 2007 at 22:00 UTC
    "-d" works , but the script i am using , it picks up the parent directory too.
    So it moves F:\test itself into the destination directory
    but i want only the directories within F:\test and
    and older than 10 days to be moved to F:\old
    SCRIPT is below :-
    use File::stat;
    use Time::localtime;
    use File::Find;
    my @files = ();
    my @paths = ();
    my $dir = 'F:\\test';
    print "Dir - $dir \n";
    find(\&_filewanted, $dir);
    if (@dirs < 1) {
    print "\n There are no files older than 10 days \n";
    } else {
    print "\nThe Following files are older than 10 days and are
    being moved\n";
    for my $file ( @dirs ) {
    $file =~ s/\//\\/;
    print " FILE NAME : $file\n";
    system("move $file F:\\old");
    print "Moved $file to F:\\old\n";
    }
    }
    print "\n";
    sub _filewanted {
    if ( ((-M $_) > 10) && -d $_ ) { # directories not files
    push @dirs, $File::Find::name;
    }
    }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://648433]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found