Merge 3 text files line by line using batch file. The lines contains specials char. and spaces

前端 未结 1 1814
长发绾君心
长发绾君心 2021-01-28 06:10

Hello i want to merge 3 text files line by line using batch file. The lines contains specials char. and spaces. if file has only one line the code below works but if we have mu

相关标签:
1条回答
  • 2021-01-28 06:25

    I just copied the answer from this site and extended it to 3 files. I can't provide a more precise solution without further details...

    @echo off
    setlocal EnableDelayedExpansion
    rem First file is read with FOR /F command
    rem Second file is read via standard handle 3
    rem Third file is read via standard handle 4
    3< b.txt 4< c.txt (for /F "delims=" %%a in (a.txt) do (
       rem Read next line from b.txt
       set /P lineB=<&3
       rem Read next line from c.txt
       set /P lineC=<&4
       rem Echo lines of three files
       echo %%a,!lineB!,!lineC!
    ))
    
    0 讨论(0)
提交回复
热议问题