in reply to splitting directories

Just use any of the many algorithms to split an array into smaller chunks. The simplest is to splice until an array is empty:

use strict; use Fatal qw(chdir opendir mkdir rename); chdir "..."; opendir my $dh, "."; my @files = grep !/\A\.\.?\z/, readdir $dh; my $index = 0; while (@files) { my $dir = sprintf "images%02d", $index++; mkdir $dir; rename $_, $dir for splice @files, 0, 1000; }
This code is dirty and untested. Don't use it unless you fully understand what it does.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }