Ways to Combine Two (or More) Text Files

by Barry Dysert
(last updated February 22, 2016)

2

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:

  1. Right-click on the desktop or in a folder and choose New | Text Document from the resulting Context menu. Windows obligingly creates a new text document for you.
  2. Name the text document anything you like, such as "Combined.txt".
  3. Open the newly created text file in Notepad.
  4. Using Notepad, open a text file you want combined.
  5. Press Ctrl+A. All the information in the text file is selected.
  6. Press Ctrl+C. All the selected information is copied to the Clipboard.
  7. Select the text file you opened in step 3.
  8. Press Ctrl+V. All the information is pasted into the text file.
  9. Close the text file you opened in step 4.
  10. Repeat steps 4 through 9 for each of the other text files you want combined into the new one.
  11. Save the text file that contains the combined information.

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.

Author Bio

Barry Dysert

Barry has been a computer professional for over 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...

MORE FROM BARRY

Using the DiskPart Utility

The DiskPart utility is a low-level command-line program that lets you manage disks, virtual disks, partitions, and volumes. ...

Discover More

DesktopOK

Are you frustrated by your desktop icons moving around whenever you change your screen resolution or use Remote Desktop? ...

Discover More

Limiting the Number of Login Attempts

You probably don't want to allow someone to continually attempt to login to your system until they finally guess your ...

Discover More
More WindowsTips

Moving Files or Folders

A common operation within Windows is to move files and folders from one location to another. Here are the two major ways that ...

Discover More

Rebuilding the Search Index

There may be times when you want to reset the search index and rebuild it from scratch. This tip tells you how.

Discover More

Copying Data with Robocopy

Robocopy is a robust file copy utility built into Windows. If you have a lot of file management to do that can't easily be ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five minus 0?

2016-12-05 13:54:38

Lisa Coffey

You are a genius. Thank you.


2016-02-22 11:06:30

Stephen Gray

What I really want in Word is a true Paste And Keep Source Format. It does not exist. There's something by that name but it has various requirements and limitations. I regard its lack as a major screwup.


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.