Merge text files

Author: Roger Morrison
Date Of Creation: 27 September 2021
Update Date: 1 July 2024
Anonim
How to Combine Text (.txt) Files
Video: How to Combine Text (.txt) Files

Content

If you have a number of text files on your computer that you would like to merge, you can do this with a simple command in the Command window. This is useful for a variety of things, including word lists and libraries, and can be useful for further folder cleanup.

To step

  1. Via the Command window, go to the directory (folder) where you have all the text files (.txt) that you would like to merge.
  2. Left click on an empty space in the folder to make sure you've selected everything, and hold CTRL+Shift and right click in an empty space.
  3. You will see the option Open command window here, and select it so that the command prompt automatically targets the directory when opening, before running the merge command.
    • If you don't see this option, go to the Start menu and search for "cmd" and open "cmd.exe" - If you are using XP, click Run and type "cmd". Did you open it successfully, then type cd C: and navigate to the directory containing the text files. For example: suppose you have a folder files on your Desktop, then type cd C: Users User Desktop files, replacing "User" with the username you logged in with.
  4. Now that the Command Window is open and focused on the directory containing the text files, we can run the following command.for% f in ( *. txt) do type "% f" output.txt This command will select all of the .txt files in the directory and run them merged into a new text file called output.txt, which you can name as desired.
    • Show each new line after reading each file, because any new file added to the merged file will start at the end of the last current line.

Tips

  • It is better to save the newly merged file elsewhere than with the original files, or use a different extension than .txt. Otherwise, a recursive error will occur.
  • If you do not want to type this command yourself in the Command window, you can copy the code and right-click in the command window, after which you click "Paste".
  • Once you have checked the resulting file and the text files are properly merged, you can delete the text files you no longer need.

Warnings

  • Do not try this on another operating system such as Linux or Mac OS as the commands and steps may not work or be supported by the operating system. If you do this anyway, you do this at your own risk.
  • Make sure the command window focuses on the specific directory where the text files reside, otherwise you might try to merge all the files from your hard drive, which could cause your PC to crash or become very slow.
  • When using the "cd" command, the resulting directory will depend on your operating system and specific computer.

Necessities

  • Preferably Windows XP, Vista, 7 or 8.