Page 1 of 1

text merge

Posted: 10 Jun 2013 08:46
by krunoo
Hello,

cant someone help me.

I have to txt file with text. something like this:

1.txt
1
2
3
4

2.txt
a
b
c
d

and I need to get this:

output.txt
1 a
2 b
3 c
4 d

Is there a way to get this with .bat script?

Thanks everyone,
Kruno

Re: text merge

Posted: 10 Jun 2013 09:01
by foxidrive
file1.txt and file2.txt are the input files.

Code: Select all

@echo off
setlocal DisableDelayedExpansion
< file2.txt (
   for /F "delims=" %%a in (file1.txt) do (
      set file2Line=
      set /P file2Line=
      set "file1Line=%%a"
      setlocal EnableDelayedExpansion   
      echo(!file1Line! !file2Line!
      endlocal
   )
) >output.txt
pause

Re: text merge

Posted: 10 Jun 2013 09:09
by krunoo
perfect.

Thank youuu!!!!