Solved Batch to merge text lines

April 23, 2015 at 03:36:49
Specs: Windows 7
I have a text file with muliple information divided in three and three lines, and need a windows batch script to merge the lines;e.g.:

A 44 5 56 345
1 34 23
4 55
B 43 34 56 345
1 34 23
78 65
Q 67 5 36 245
1 44 3
4 45

To this
A 44 5 56 345 1 34 23 4 55
B 43 34 56 345 1 34 23 78 65
Q 67 5 36 245 1 44 3 4 45


See More: Batch to merge text lines

Report •

#1
April 23, 2015 at 09:25:48
✔ Best Answer
@echo off & setlocal EnableDelayedExpansion
set cnt=3
for /F "delims=" %%a in ('type "input.txt"') do (
  set /A cnt-=1
  set row=!row! %%a
  if !cnt! equ 0 (set cnt=3& echo.!row:~1!& set row=)
) >> "output.txt"


Report •

#2
April 23, 2015 at 22:12:52
Perfect, just what I wanted. Thanks

Report •
Related Solutions


Ask Question