How to Merge Text (.Txt) Files in Command Prompt

Navigate and open the directory (folder) where all the text (txt) files are located which you'd like to merge together are located in Command Prompt., Left click a blank space in the folder to ensure you haven't selected anything and hold CTRL +...

6 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Navigate and open the directory (folder) where all the text (txt) files are located which you'd like to merge together are located in Command Prompt.

    If you didn't see that option, go to your Start Menu and search for "cmd" and open "cmd.exe"
    - If you're using XP, click Run and type in "cmd".

    Once you've successfully opened it, type cd C:\ and navigate to the directory with the text files in it.

    For example, I have a folder called ' files ' on my Desktop, I'd type cd C:\Users\User\Desktop\files and you should replace 'User' with the account name you're logged in to. , forĀ %f in (*.txt) do type "%f" >> output.txt This command will select all the text (.txt) files in the directory and output them all merged together into the new text file called output.txt which you can rename to whatever you like.

    Echo each new line after reading each file, as every new file written to the merged file will start at the end of the last current line.
  2. Step 2: Left click a blank space in the folder to ensure you haven't selected anything and hold CTRL + Shift and Right click in a blank space.

  3. Step 3: You will see the option Open command window here

  4. Step 4: select it so the Command Prompt has automatically been pointed to that directory while opening to continue executing the merge command.

  5. Step 5: Now Command Prompt is open and pointed to the directory with the text files in it

  6. Step 6: we can execute the following command.

Detailed Guide

If you didn't see that option, go to your Start Menu and search for "cmd" and open "cmd.exe"
- If you're using XP, click Run and type in "cmd".

Once you've successfully opened it, type cd C:\ and navigate to the directory with the text files in it.

For example, I have a folder called ' files ' on my Desktop, I'd type cd C:\Users\User\Desktop\files and you should replace 'User' with the account name you're logged in to. , forĀ %f in (*.txt) do type "%f" >> output.txt This command will select all the text (.txt) files in the directory and output them all merged together into the new text file called output.txt which you can rename to whatever you like.

Echo each new line after reading each file, as every new file written to the merged file will start at the end of the last current line.

About the Author

K

Kevin Hernandez

Experienced content creator specializing in organization guides and tutorials.

40 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: