P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
"-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; } } In reply to Re^2: How do we find the age of a directory ??
by dilip_val
|
|