Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

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

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


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

Take a look at "-X FILEHANDLE" in perlfunc


  • 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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-05-27 04:16 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (152 votes). Check out past polls.