This will do it if the files aren't the same size. The batch file counts the lines in each file and compares the line counts. If one file has more lines than the other, the shorter one will output empty lines for missing lines in file with less lines.
Personally I would go this route then just fix the blank lines with PowerShell if I needed this script for myself.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
pushd "\\server\folder"
set "InputFile1=File1.txt"
set "InputFile2=File2.txt"
set "OutputFile=mix.txt"
(set Newline=^
%==%
)
if not exist "%InputFile1%" goto EndBatch
if not exist "%InputFile2%" goto EndBatch
del "%OutputFile%" 2>nul
for /F "delims=:" %%I in ('%SystemRoot%\System32\findstr.exe /R /N "^" "%InputFile1%"') do set "LineCount1=%%I"
for /F "delims=:" %%I in ('%SystemRoot%\System32\findstr.exe /R /N "^" "%InputFile2%"') do set "LineCount2=%%I"
rem Exchange input file 1 and 2 if input file 2 has more lines than input file 1.
if %LineCount2% GTR %LineCount1% set "InputFile1=%InputFile2%" & set "InputFile2=%InputFile1%"
(
for /F usebackq^ delims^=^ eol^= %%I in ("%InputFile1%") do (
set "LineFile1=%%I"
setlocal EnableDelayedExpansion
set /P LineFile2=
echo(!LineFile1!!Newline!!LineFile2!>>"%OutputFile%"
endlocal
)
)<"%InputFile2%"
:EndBatch
popd
endlocal
pause
Lines starting with a semicolon and containing an exclamation mark are also processed well by this script. Just empty lines in the two input files are ignored and cause unexpected content in output file.
[Mofi] made some edits to this version.
If you wanted to blank the lines with PowerShell like I suggested then save this as clearlines.ps1
and then run it from your batch file at the end.
$pathToFile = "\\server\folder"
(Get-Content -Path $pathToFile) -notmatch '(^[\s,-]*$)| (rows\s*affected)' | Set-Content -Path $pathToFile