in reply to Re: Moving files to subfolders based on their last modified date
in thread Moving files to subfolders based on their last modified date

$mday = sprintf('%02d', $mday) ; # Not used in this script, but ret +urns a 2 digit day $mon = sprintf('%01d', ++$mon) ; # Returns a 1 digit month un +til we get to 10 then use 2, not my choice. $year = 1900 + $year ; # Returns a 4 digit year $outdir = "_" . $year . "\\" . $mon . "\\" ; # Build the direc +tory name based on date where the file is going \_2011\9\
Even simpler is (which replaces some of the code above that also):
my $ym = Time::Piece->new($mtime)->strftime("%Y\\%m"); # For single digit month: $ym =~ s/0(\d)$/$1/; my $outdir = "_$ym\\";
Update: Although in the OP I now notice that a single digit month (where possible) is required...so a further tweak would be required to this (updated again to reflect this).