How to find newest files in a directory, including subdirectories?

Solution 1:

If you're still interested in a scripted solution, I've quickly thrown something together which will display files from all directories together:

#!C:/Perl/bin/perl.exe
use File::Find;

my %files = ();

sub process
{
    $files{$_} = (stat($_))[9] unless -d $_;
}

find (\&process, $ARGV[0]);

foreach my $key(sort {$files{$b} <=> $files{$a}} keys %files)
{
    print "$key\n";
}

Files are displayed newest to oldest, showing only the file name. This way you can easily pipe the output of this script to another tool for processing without having to worry about stripping excess output.

Usage: perl find.pl <starting_directory>

Solution 2:

Like this: dir /s /o:-d