in reply to Using -mtime in File::Find::Rule seems to fail on Windows

The timestamps return by -M, -C & -A are relative to the start of the program. So to find those less than 24 hours old you need to specify 1, not -1; that would be in the future.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
  • Comment on Re: Using -mtime in File::Find::Rule seems to fail on Windows

Replies are listed 'Best First'.
Re^2: Using -mtime in File::Find::Rule seems to fail on Windows
by neniro (Priest) on Jul 20, 2004 at 14:04 UTC
    Of course I tried this before with the same effect. I tried '-1' because it's the way unix-find finds files modified between the last 24 hours. '1' means exactly 24 hours.

      Sorry. I'm not a F::F::R user. However a quick look at the docs suggests that

      ->mtime( '<= 1 ' )

      should do the trick.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
        I found an example at the Perl-Advent-Calendar. It uses unix-time in seconds. I've changed my script and it works fine now.
        #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Date::Calc qw/ Time_to_Date /; use File::Find::Rule; my $yesterday = time()-(1*24*60*60); print $last_week, "\n"; my @files = File::Find::Rule->file() ->name( '*.doc' ) ->mtime( ">$yesterday" ) ->in( 'D:/Dokumentation/' ); @files = map { { name => $_, #modified => [Time_to_Date((stat($_))[9])], size => (stat($_))[7] } } @files; print Dumper \@files;
        Thanks in advance, neniro