When I have a folder with about 5000 images and I use the following code:
my $path= "./foo/images"
my @files = File::Find::Rule->file()->name('*.jpg')->in($path);
I should get 5000 Images in my Array.
But are there equivalents with perl or a shell function like tail
and head
, or any other way, to get the last 100 images for example?
Just realised... File::Find::Rule completly mixes up the images... so we need a sort additionally before slicing the Array
so finally I/we have to use the following:
for the first 5:
my @files = (sort File::Find::Rule->file()->name('*.jpg')->in($path))[0 .. 4];
for the last 5:
my @files = (reverse sort File::Find::Rule->file()->name('*.jpg')->in($path))[0 .. 4];