I am using a basic command line program to convert .xml files to .csv. I have it performing the action on all .xml files in the directory using
FOR %I in (..\xmlinput\*.xml) DO XmlToCsv.Console.exe -xml %I -dir ..\csvoutput\
This works fine but all output files are named r.csv, so each time it loops the previous r.csv is overwritten. How can I incrementally rename the output (r1.csv, r2.csv, etc.) before the next loop runs and overwrites the previous output? (the XmlToCsv.Console.exe has no additional parameters to use). Many thanks.
In a batch-file, you can try this:
@echo off
setlocal EnableDelayedExpansion
set "counter=1"
FOR %%I in (..\xmlinput\*.xml) DO (
XmlToCsv.Console.exe -xml %%I -dir ..\csvoutput\
ren "..\csvoutput\r.csv" "r!counter!.csv"
set /a "counter+=1"
)
Note that because this is a batch-file and not a single command you need to use %%I
instead of %I
. You might also need to change the paths for the rename command.