Batch processing of string splicing

Time:2021-1-12
Copy codeThe code is as follows:
@echo off
:: every 6 lines are spliced into one line, and the remaining less than 6 lines are displayed in the last line
::
::
set num=0
setlocal enabledelayedexpansion
for /f “delims=” %%i in (a.txt) do (
set /a num+=1
set str=!str! %%i
if !num! equ 6 echo !str! && set num=0 & set str=
)
if not “%str%”==”” echo %str%
pause