How to concantenate files together

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I need to concatenate 2 files together but I need the data
from the files to be on the same line. Example:
File1 simply contains a file name:
filename.bas
File2 has the path to that file
f:\wicshare\garprod\

I need the single file to display as
filename.bas f:\wicshare\garprod

I am attempting to do this multiple times in a batch file.
 
Chris said:
I need to concatenate 2 files together but I need the data
from the files to be on the same line. Example:
File1 simply contains a file name:
filename.bas
File2 has the path to that file
f:\wicshare\garprod\

I need the single file to display as
filename.bas f:\wicshare\garprod

I am attempting to do this multiple times in a batch file.

Well, here's one way that works for files named File1 and File2 :-)
You weren't specific enough about 'multiple times in a batch file',
and my crystal ball needs new batteries. . . . But the gist is
as follows:

- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>type %temp%\file1
filename.bas

C:\cmd>type %temp%\file2
f:\wicshare\garprod\

C:\cmd>demo\CombineFiles
filename.bas f:\wicshare\garprod\

C:\cmd>rlist demo\CombineFiles.cmd
=====begin C:\cmd\demo\CombineFiles.cmd ====================
1. @echo off
2. setlocal
3. for /l %%a in (1,1,2) do call :main %%a
4. echo %rec% > c:\temp\File3
5. type c:\temp\File3
6. goto :EOF
7. :main
8. set /p input=<c:\temp\file%1
9. set rec=%rec%%input%
=====end C:\cmd\demo\CombineFiles.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -
 
Hello Chris.

Chris said:
I need to concatenate 2 files together but I need the data
from the files to be on the same line. Example:
File1 simply contains a file name:
filename.bas
File2 has the path to that file
f:\wicshare\garprod\

I need the single file to display as
filename.bas f:\wicshare\garprod

I am attempting to do this multiple times in a batch file.

My solution creates every combination of lines in file1 and file2:
@echo off
setlocal enableextensions
set file1=file1.txt
set file2=file2.txt
set file3=file3.txt
if exist %file3% del %file3%
for /f %%t in (%file1%) do for /f %%u in (%file2%) do echo %%u%%t>>%file3%
endlocal
 
Back
Top