Written by Barry Dysert (last updated November 18, 2019)
If you have a couple (or more) text files that you'd like to combine into one larger text file, Windows provides a few ways to do it. Which way you choose will likely depend upon how many files you want to combine, how big they are, and how comfortable you are with the different approaches.
One approach that may first come to mind is the copy/paste approach. This lets you stay within the familiar Windows environment while still accomplishing your goal. Follow these general steps:
Obviously, this is a very tedious approach—especially if you have more than a couple of files to be combined. The other approaches are much faster, but they do require that you do the work at the command line.
Probably the simplest command-line approach to use in combining files is to use the Copy command. With Copy, you can specify a number of files as inputs and one file as an output file. This will then copy all of the input files into the one output file, and you're done. Your command line might look something like this:
C:\> copy in1.txt + in2.txt + in3.txt Combined.txt
This will copy the files "in1.txt", "in2.txt", and "in3.txt" to a file called "Combined.txt". (The Combined.txt file is automatically created by the Copy command. If Combined.txt previously existed, it is overwritten by the command.) The Copy command supports wildcards, too, so if your file names follow a standard format, you could even do it this way:
C:\> copy in*.txt Combined.txt
This is probably the best approach to take, but if you prefer a more esoteric solution you could try either of two variations of the Type command. For example,
C:\> type in*.txt > Combined.txt
This types the contents of all of your "in" text files and sends the output to your "Combined.txt" file. If the Combined.txt file previously existed, it is overwritten by this command.
The second variation of the Type command also uses the For command. In this variation, the "in" files are cycled through one at a time and their contents are appended to your "Combined.txt" file:
C:\>For %f in (in*.txt) do type %f >> Combined.txt
These are all interesting ways to attack the problem, but my favorite is the simple Copy command.
This tip (5670) applies to Windows 7, 8, and 10.
Need to add some additional drive space to your system? Why not consider adding what Microsoft calls a "storage space?" ...Discover More
Searching from within File Explorer is a quick and easy way to find files and even content within files. This tip shows ...Discover More
If you need access to files on a network but aren't always on the network, you may find that the offline files feature of ...Discover More