Reputation: 1
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
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
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