2014-09-27 2 views
0

나는 창과 명령 줄에만 액세스 할 수 있습니다.텍스트 파일의 줄에 다른 텍스트 파일의 줄을 추가하십시오.

필자에게는 file1과 file2라는 줄이 많은 두 개의 텍스트 파일이 있습니다. file2의 해당 줄과 file1의 줄을 추가하고 싶습니다.

파일 1의 각 행은 다음과 같습니다

apple Orange 

파일 2의 각 행은 다음과 같습니다

apple Orangebanana 

:

banana 

I 출력은 다음과 같이 할 어떤 아이디어? 가급적 승리 명령 프롬프트를 통해?

+0

가능한 중복으로 그들을 인터리브 12342764/how-do-i-app-to-a-file-using-copy-command) – Im0rtality

+0

@ Imality 참조 된 링크는 텍스트 파일을 차례대로 추가하여 병합하는 반면 파일을 한 줄씩 추가하려고합니다 ,이 리눅스 예제와 유사 : [링크] (http://stackoverflow.com/questions/16394176/how-to-merge-two-files-consistently-line-by-line) – BrettH

답변

1

이 입력 파일로 file1.txtfile2.txt를 사용하고 (http://stackoverflow.com/questions/ [I가 COPY 명령을 사용하여 파일을 추가하려면 어떻게]의 result.txt

@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 
    ) 
) 
)>"result.txt" 

pause 
+0

완벽! 고마워. – BrettH

관련 문제