perl script to list size and modified name of files in folder

Hello. I have a folder with about 3600 files in it. The files have names like

I would like to get a csv file which consists of the modified names of the files and their file sizes (either mb or kb is ok). By modified name, I just want the year, month and day so that for example
would become
and if this file was 25.2 mb the entry for this file would be
11-05-26, 25.2
Can anyone help me with this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What is there are several files for single day, like in your example? 11-05-26 has 4 files.
onyourmarkAuthor Commented:
Hi. Thanks for the reply!

Even if there are several files a day there can be a separate row for each one.

So it could look like

11-05-26, 25.2
11-05-26, 30.2
11-05-26, 20.8
11-05-26, 35.5

or something like that.

Thanks again.

How about something like this
use warnings;
use strict;

my @files = <*csv>;
foreach my $file (@files)
    my $size = (stat($file))[7];
    $file    =~ s/_.*//;
    print '"', join('","', ($file, $size )) , '"', "\n";

Open in new window

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

onyourmarkAuthor Commented:
Hi. Thanks. To try this I should make it a file called something like and put it in the same directory as the files and then run it like
cd C:/appropriate directory

Is this correct?

Yes.  Or if you want to run it from a different directory, you will have to change <*csv> part.
print /([^_]*)/,", ",(-s)/1024,"\n" for <*.csv>;
onyourmarkAuthor Commented:
how can I have the result written to a file called sizes.csv?
You can redirect the output by using > > sizes.csv
onyourmarkAuthor Commented:
Hi. Thanks again.
I think I may have specified this incorrectly.

A file like 11-05-26_08-00-01_sina.csv
would be 2011/5/26

but it is reading it as  11/5/2026.

is this hard to rearrange?
open STDOUT,">sizes.csv" or die $!;
printf "20%02d/%d/%d, %.3f\n",/(\d+)-(\d+)-(\d+)/,(-s)/1000 for <*.csv>;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
onyourmarkAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.