Working with CSV Files

I have a folder of csv files with a random filename and I want to rename the filename with some text within the csv file which is relevant. Any help?
Nick CollinsAsked:
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.

LET (Learn Excel in Tamil)Reporting Automation ExpertCommented:
Answer is, Yes possible, if advise which field  name you exactly want from the CSV data as a file name.

Thanks
Learn excel in Tamil
Happy learing
0
Nick CollinsAuthor Commented:
Each CSV file is quite large but I am only interested in a small section of the file.
0
Nick CollinsAuthor Commented:
I'll attached an example for you. I would like to extract some of data under column C titled Response.

Row 3 Named Client Site Job Number
Row 4 Order Number
Row 5 Completed On

I would like three above to be the filename

Thanks
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
How to identify which CSV files have already be changed to the new file name? Is there a pattern for the random part versus the new name?
0
Nick CollinsAuthor Commented:
The CSV files old name all begin with template_
0
aikimarkCommented:
waiting for you to post a sample csv file
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Without seeing an example CSV file, and allowing myself to suggest a solution in PowerShell:
get-childitem C:\CSVfiles\template_*.csv |
% {
  $data = (get-content -totalCount 5 $_ | convertFrom-CSV | select -skip 2 -Expand response) -join '-'
  $_ | rename-item $data
}

Open in new window

This would rename to «Named Client Site Job Number»-«Order Number»-«Completed On».csv, with «...» replaced by the corresponding values.
0

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
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
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.