Solved Use a batch file to rename files with a CVS

February 4, 2012 at 22:44:50
Specs: Windows XP
I'm working on making a batch that rename files base on cvs file. I will look in a input dir for a file containing the whats in the first part of the cvs, then move and change the name to what in the seconded part of the cvs.

so it should work like this...


the batch file would look in the C:\input for a file name A3.txt then when it finds it. the batch would move the A3.txt to C:\output with the new name of 09.txt

thanks for any help.

See More: Use a batch file to rename files with a CVS

Report •

February 5, 2012 at 06:57:55
✔ Best Answer
@echo off
for /F "tokens=1-2 delims=," %%a in (Master.csv) do (
  if exist "C:\input\%%a.txt" move "C:\input\%%a.txt" "C:\output\%%b.txt"

Report •

February 5, 2012 at 07:22:00
Thanks, but that only worked on the top line of cvs. can it loop through each line?

Report •

February 5, 2012 at 07:53:41
Are you sure?

I have a huge experience in For /F statements and do assure the code I posted browses the whole Master.csv file performing the if exist for each line inside.

Report •

Related Solutions

February 5, 2012 at 08:14:25
that was my bad i was using some bad sample data..

Thanks so much.

Report •

Ask Question