使用 File::Find
use
File
::
Find;
use Time :: Piece;
$timeOneDay = 86400 ;
$dayMultipler = 1 ;
$ByteCount = 0 ;
$fileAll = 0 ;
$fileJpg = 0 ;
$fileYes = 0 ;
$pathToTra = " . " ;
$gt = localtime ;
$t1 = $gt -> epoch;
find( \& fileThumb , $pathToTra );
$gt = localtime ;
$t2 = $gt -> epoch;
print " Total KByte: " . ( $ByteCount / 1024 ) . " \n " ;
print " Total Scan: " . $fileAll . " \n " ;
print " Total Jpeg: " . $fileJpg . " \n " ;
print " Total Match: " . $fileYes . " \n " ;
print " Total TimeCost: " . ( $t2 - $t1 ) . " \n " ;
sub fileThumb
{
$fileAll ++ ;
if (( /.*\. jpg$ / ) )
{
$fileJpg ++ ;
my $lt = 0 ;
$lt = localtime ;
my ( $dev , $ino , $mode , $nlink , $uid , $gid , $rdev , $size , $atime , $mtime , $ctime , $blksize , $blocks ) = stat ( $_ ) or die " Unable to stat $_\n " ;
if ( $mtime < ( $lt -> epoch - $timeOneDay * $dayMultipler ) )
{
print " [ $fileYes ] " . " $File::Find::name " ;
print $size . " " . $ctime . " " . $lt -> epoch . " \n " ;
$ByteCount += $size ;
$fileYes ++ ;
}
}
}
本文转自博客园刘凯毅的博客,原文链接:perl file find,如需转载请自行联系原博主。
use Time :: Piece;
$timeOneDay = 86400 ;
$dayMultipler = 1 ;
$ByteCount = 0 ;
$fileAll = 0 ;
$fileJpg = 0 ;
$fileYes = 0 ;
$pathToTra = " . " ;
$gt = localtime ;
$t1 = $gt -> epoch;
find( \& fileThumb , $pathToTra );
$gt = localtime ;
$t2 = $gt -> epoch;
print " Total KByte: " . ( $ByteCount / 1024 ) . " \n " ;
print " Total Scan: " . $fileAll . " \n " ;
print " Total Jpeg: " . $fileJpg . " \n " ;
print " Total Match: " . $fileYes . " \n " ;
print " Total TimeCost: " . ( $t2 - $t1 ) . " \n " ;
sub fileThumb
{
$fileAll ++ ;
if (( /.*\. jpg$ / ) )
{
$fileJpg ++ ;
my $lt = 0 ;
$lt = localtime ;
my ( $dev , $ino , $mode , $nlink , $uid , $gid , $rdev , $size , $atime , $mtime , $ctime , $blksize , $blocks ) = stat ( $_ ) or die " Unable to stat $_\n " ;
if ( $mtime < ( $lt -> epoch - $timeOneDay * $dayMultipler ) )
{
print " [ $fileYes ] " . " $File::Find::name " ;
print $size . " " . $ctime . " " . $lt -> epoch . " \n " ;
$ByteCount += $size ;
$fileYes ++ ;
}
}
}