Merging Text Files

dreacat

Commendable
Nov 7, 2016
1
0
1,510
I need to create a batch file that merges two text files into one file:

file1.txt contains:
lname1 fname1 email1

file2.txt contains:
lname2 fname2 email2

I need the merged output file to contain:
lname1 fname1 email1
lname2 fname2 email2
 
Solution
[strike]<driveletter>:
cd \<location of the files>
type *.txt > consummated
end[/strike]

Disregard my initial batch try this one below

<<Alternative Batch>>

<driveletter>:
cd \<location of the files>
type <first file>.txt; <file containing a line space>.txt; <second file>.txt > consummated.txt
end


In your case it might look like this:

C:
cd \users\user1\documents\files
type file1.txt; line.txt; file2.txt > consummated.txt
end

NOTE: This overwrites anything in the destination file so if you want to merge more than two files then you must do them all at once. This command does not remove the original files so if you have a new file that you want to add simply add it in the line of the batch.

harrysmellington

Reputable
Jun 23, 2016
188
0
4,760
[strike]<driveletter>:
cd \<location of the files>
type *.txt > consummated
end[/strike]

Disregard my initial batch try this one below

<<Alternative Batch>>

<driveletter>:
cd \<location of the files>
type <first file>.txt; <file containing a line space>.txt; <second file>.txt > consummated.txt
end


In your case it might look like this:

C:
cd \users\user1\documents\files
type file1.txt; line.txt; file2.txt > consummated.txt
end

NOTE: This overwrites anything in the destination file so if you want to merge more than two files then you must do them all at once. This command does not remove the original files so if you have a new file that you want to add simply add it in the line of the batch.
 
Solution