Selvakumar has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; my $today = time; my @rootfolders=("d:/temp/"); for my $folder (@rootfolders) { $folder=~s/\\/\//g; $folder=$folder."/"; $folder=~s/([\/]+)$/\//; opendir(DIR,"$folder"); for my $temp (readdir(DIR)) { if (!(($temp eq ".") || ($temp eq ".."))) { print "$folder$temp"; my $temp1=$folder.$temp; my $mtime = (stat "$temp1") [9]; my ($sec,$min,$hour,$day,$month,$year) = localtime($mtime); $month++; print " $month/$day/$year $hour:$min "; #I am trying to find here 12:00 AM in the morning time.so the files sh +ould be exactly three days back. ($sec,$min,$hour,$day,$month,$year) = localtime($today); if ($hour > 1) { $hour=$hour*60*60; } my $findtime=$sec+$min+$hour; $today=$today-$findtime; my $older=(60*60*24)*3; $today=$today-$older; ($sec,$min,$hour,$day,$month,$year) = localtime($today); $month++; if ($today > $mtime) { print " OLDER 3 days"; } if (-d $temp1) { print " is a folder\n"; } else { print " is a FILE\n"; } } } close(DIR); }
d:/temp/BBDPS0478M_ITR.pdf 7/30/109 17:13 OLDER 3 days is a FILE d:/temp/Binder1.pdf 6/12/109 19:20 OLDER 3 days is a FILE d:/temp/bri.doc 8/1/109 15:32 is a FILE d:/temp/Can be delete.xls 2/18/109 16:4 OLDER 3 days is a FILE d:/temp/doc 8/3/109 15:52 is a folder d:/temp/Docx 8/3/109 15:52 is a folder d:/temp/ps 8/3/109 15:52 is a folder d:/temp/screenshot.bmp 7/31/109 17:51 is a FILE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: older files
by moritz (Cardinal) on Aug 04, 2009 at 06:37 UTC | |
|
Re: older files
by merlponk (Scribe) on Aug 04, 2009 at 06:59 UTC | |
by Selvakumar (Scribe) on Aug 04, 2009 at 07:38 UTC | |
by derby (Abbot) on Aug 04, 2009 at 11:16 UTC |