Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

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 ??
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
Node Status?
node history
Node Type: note [id://648433]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2014-09-18 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (109 votes), past polls