First, apologies for my poor coding ability, however I have spent a few hours reading the forums and giving it a crack, so I would really appreciate any help with the follow
@echo off
setlocal EnableDelayedExpansion
if exist result.csv del result.csv
for %%f in (*.txt) do (
set i=0
for /F "delims=" %%l in (%%f) do (
set /A i+=1
set line!i!=%%l
)
echo %%f, !line3!, !line5!, !line7! >> result.csv
)
This Batch file process all .txt files in the directory, as you said.
You could read the lines with another construct.
setlocal EnableDelayedExpansion
< %1 (
Set /p line1=
Set /p line2=
Set /p line3=
Set /p line4=
Set /p line5=
Set /p line6=
Set /p line7=
)
Echo %1,!line3!,!line5!,!line7!
Or with a loop (Andriy)
Setlocal EnableDelayedExpansion
<%1 (
For /L %%n in (1 1 7) do (
Set /p line%%n=
)
)
Echo %1,!line3!,!line5!,!line7!