使用批处理文件逐行合并3个文本文件.这些行包含特殊字符char.和空格 [英] Merge 3 text files line by line using batch file. The lines contains specials char. and spaces

查看:104
本文介绍了使用批处理文件逐行合并3个文本文件.这些行包含特殊字符char.和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想使用批处理文件逐行合并3个文本文件. 这些行包含特殊字符char.和空格. 如果文件只有一行,则下面的代码可以工作,但是如果我们有多行文本,则ti不会 因为重新库存是:

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 multiline text ti doesnt Because the resault is:

1stline1stline 1stline2stline 2stline1stline 2stline2stline 示例代码

1stline1stline 1stline2stline 2stline1stline 2stline2stline Example code

@echo off
for /f "delims=" %%a in (a.txt) do (
    for /f "delims=" %%b in (b.txt) do (
        >>c.txt echo %%a %%b
    )
)

推荐答案

我刚刚从

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!
))

这篇关于使用批处理文件逐行合并3个文本文件.这些行包含特殊字符char.和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆