- Discover all the methods to join TXT files in Windows without extra programs.
- Compare options: line of commands, batch files, PowerShell and online tools.
- Avoid common mistakes and resolve questions about file order, subfolders, and compatibility.

Have you ever found yourself with a bunch of scattered .txt files and needed to consolidate all that information into one? You're not alone. Combining multiple text files into a single document is a common solution for programmers, analysts, and anyone who handles large volumes of data or records. Best of all, you can do it in seconds without installing any programs, just using the Windows command prompt. In this guide, I'll explain it in detail and in a clear, user-friendly way so you'll understand it right away, even if you've never used CMD or PowerShell before.
Furthermore, I'll show you all the available methods for merging .txt files: from the simplest commands to automated alternatives, including online solutions, PowerShell, Excel, and even Python scripts . This way, you can choose the method that best suits your needs, regardless of your situation or technical skill level.
Why merge multiple txt files into one?
Before we get into the details, it's worth clarifying why merging text files can be the best option in many cases. Managing dozens or hundreds of separate files is a nightmare: copying, pasting, searching for information, analyzing… everything becomes complicated. Merging them into a single file makes it easier to:
- Manage bulk registrations de logs, data exports or reports from different days.
- Import unified information to Excel or Google Sheets quickly.
- Avoid errors or duplications when copying content manually.
- Reuse the combined file for future processes, making work repeatable and efficient.
Whether it's to consolidate information, analyze large batches of data, or simply for organization, knowing how to combine text files from the console is a trick that will save you time and headaches.
Classic Method: Merge TXT Files from Windows CMD Console
The Windows operating system offers several ways to merge text files, but the most traditional and versatile is by using its command prompt, known as CMD ( Command Prompt ). You don't need to install anything: it comes included by default.
First step: Organize the files you are going to merge.
- Put them all in the same folder and, if order is important, give them sequential names (for example, 1.txt, 2.txt, 3.txt…)
- If you wish, make a copy of the files to save the original in case something goes wrong.
Now follow these basic steps:
- Open Command Prompt (CMD). Use the combination Windows + R, writes cmd and hit Enter.
- Navigate to folder where you have the files with the command cd folder_path. For example: uterine
cd C:\Usuarios\TuNombre\Documentos\TXT - Merge all files into a new one using the simplest command:
copy *.txt archivo_final.txt
This will create final_file.txt with the contents of all text files in that folder, included in the order decided by the file system.
If you only want to merge specific files or follow a specific order, put the names like this:
copy 1.txt + 2.txt + 3.txt archivo_final.txt
This way you avoid order problems and, if the destination file already exists, the contents will be added to the end of whatever that file already had.
Alternative commands in CMD and PowerShell
Another classic option is to use the type command , very useful in Windows:
type *.txt > todos_unidos.txt
This command displays the contents of all the .txt files in the folder and, using > , saves the result to the new file todos_unidos.txt . It works similarly to the previous command, although it does not add separator lines between the files.
Many advanced users prefer to open a window of PowerShell From the folder with the TXT, execute cmd to switch to the classic console, and then launch the command. To open PowerShell from a folder:
- Right-click on the folder background and select “Open PowerShell window here.”
In PowerShell you can run the exact same commands above, although if you're looking for something more advanced, you can use loops to merge only files that meet certain conditions, include subfolders, etc. Example of a loop to merge txt files even in subfolders:
for /R %f in (*.txt) do type "%f" >> unidos_subcarpetas.txt
This command searches for all .txt files within the folder and its subfolders and dumps the contents into unidos_subcarpetas.txt.
Merge TXT files using a Batch (.bat) file
Do you repeat this process often? Automate it with a batch file (.bat), the classic Windows script . This way you can run the merge of all the files whenever you need to, saving even more time.
- Create a new file in the folder where your TXT files are and give it whatever name you want, for example, merge.bat.
- Edit the file (right click, 'Edit') and type the command:
copy *.txt resultado.txt - Save and close. Double-click on merge.bat and that's it! It will be generated result.txt with the union of all the files.
Remember that if you have previously saved a 'resultado.txt' file in the folder, it will also be included in the next merge , so delete it before running the batch file, or use different names each time to avoid duplicates.
Merging text files from the web: online options and their risks
If you're too lazy to use the console or want an even simpler method (although less secure for private files), there are free online services for merging TXT files:
- Aspose TXT Merger: Simply drag the files into the box, click 'Merge', wait a few seconds, and the combined file will download.
- FileFormat TXT Merger: Similar, although it usually allows you to choose the output format (for example, PDF, DOCX, HTML, etc.).
These methods are fast but not recommended for confidential information , since you upload your data to an external server and have no control over what happens to it. Use them only for files that do not contain sensitive data.
Join TXT files in Excel using Power Query
Need to combine multiple .txt files for analysis in Excel? Use Power Query (included in Office 365 and recent versions of Excel). The process involves:
- Open Excel, go to Data > Get Data > From a File > From a Folder.
- Select the folder containing the TXT files. Excel will detect the available files.
- Select 'Combine and Transform Data'. Choose one as the reference for the structure.
- A table will be created with the contents of all the files combined. You can save it as a single file or continue working in Excel.
This option is great for tabular data files (e.g., CSV exports, server logs, etc.). It allows for easy previewing and the application of filters, transformations, and automation from within Excel.
Advanced variants and tricks: order, subfolders, extensions
When things get complicated and we need more control, the above commands allow us to vary:
- Filter files by name:
copy ar*.txt fusionados.txt(only join those that begin with “ar”). - Working with other extensions:
copy *.log todoslogs.txt(also works with CSV, LOG, etc.). - Ensure concrete order:
copy 1.txt + 2.txt + 3.txt resultado.txt - Process subfolders: Use the loop
forin PowerShell/CMD to traverse multiple folders.
Also, if you are a user of Linux o Mac, you have the command cat to do the same:
cat *.txt > fusionados.txt
What to do if you encounter problems when merging .txt files?
Although merging files via the command line is safe and simple, some drawbacks can arise :
- Permission denied: This happens if the destination file is open or you don't have write permissions. Close any programs using it and check the permissions.
- Largest merged file in the account: This is usually due to extra line breaks or duplicate files. Clean up the source files before merging them.
- Encoding problems (rare characters): If the files have different encodings, the content may appear unreadable. Convert the files to UTF-8 or ANSI beforehand using an editor like Notepad++.
- The 'copy' or 'type' command does not work: Double-check your syntax and make sure you're in the correct directory. Don't hesitate to use quotes if the path contains spaces.
Automation with scripts and solutions for advanced users
If you prefer to take file management to the next level, you can use custom scripts :
- Batch file for advanced merge:
You can create a batch that deletes the output file before combining to avoid duplicates and displays a message when it's finished. Example:
if exist resultado.txt del resultado.txt
for %%f in (*.txt) do type "%%f" >> resultado.txt
echo Fusión completada - Merge only files with certain content:
Usafindofindstrto combine only those files that include a given keyword. - Python and other languages:
You can create a Python script to merge files, which gives you even more flexibility. A basic example:
with open('combinado.txt', 'w', encoding='utf-8') as outfile:
for fname in :
with open(fname, encoding='utf-8') as infile:
outfile.write(infile.read())
Practical tips before and after merging files
- Make a backup of the original files before merging, especially if you've never used these commands before: this way you avoid any surprises if you make a mistake with the file name or path.
- Check the combined file before deleting the originals to make sure everything is correct and the content has been merged as you expected.
- Do not use these commands with binary files (images, executables, etc.) or they will become corrupted.
- If the files have headers (column titles, for example), you'll need to remove them except for the first one so they don't appear in the final file.
Mastering how to merge multiple text files into one using the command prompt (CMD) is a quick and easy skill that can save you hours of work throughout the year. From the classic `copy` command to `type`, batch scripts, PowerShell, online utilities, or office tools like Excel, you have all the options at your fingertips to choose the one that best suits your needs and technical skill level. And if unexpected problems arise, you have tips and tricks to resolve them immediately, without complications.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.
