ketan
ketan

Reputation: 1

create a batch file

How do I create a batch script that can copy data from ten different text files into one text file, for example:

 test1.txt
 test2.txt
 test3.txt
 test4.txt

Copy data to one text file:

 final.txt = test1.txt
             test2.txt
             test3.txt
             test4.txt

Upvotes: 0

Views: 237

Answers (2)

Sodved
Sodved

Reputation: 8607

Just use the type command

type test1.txt test2.txt test3.txt text4.txt > final.txt

File contents will be written to the final.txt file, while the names of the files are written to stderr (so still appear in command prompt window). If you don't want the stderr output then

( type test1.txt & type test2.txt & type test3.txt & type text4.txt ) > final.txt

Either way, the contents of final.txt is the concatentation of all the input files.

Upvotes: 0

Mat
Mat

Reputation: 206859

You don't need a batch file, the copy command can do it all by itself:

copy test1.txt + text2.txt + ... +testN.txt final.txt

Or:

copy "test*.txt" final.txt

Upvotes: 1

Related Questions