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.

LearnReporting Automation ExpertCommented:
Answer is, Yes possible, if advise which field  name you exactly want from the CSV data as a file name.

Learn excel in Tamil
Happy learing
Nick CollinsAuthor Commented:
Each CSV file is quite large but I am only interested in a small section of the file.
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

Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Qlemo"Batchelor", 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?
Nick CollinsAuthor Commented:
The CSV files old name all begin with template_
waiting for you to post a sample csv file
Qlemo"Batchelor", 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.

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.