Join several text files into one

Member_2_5306354 used Ask the Experts™
I would like to join two as many text files that are found in C:\Files\.... into one file ending in .txt
with no lines that it finds in between the data in one text file and other etc..
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi 100questions

The term you are lookin for is concatenate.

commandline windows

copy /b c:\files\*.txt Alltogether.txt

Open in new window

Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Make sure you place the joined result file in a different folder, so that you don't concatenate it as well.


also if they are in c:\files and in subfolders, open command windows in files folder and  run below code
for /R %f in (*.txt) do type “%f” >> c:\alltogether.txt
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

But that adds a carriage return at each line....(and you added too many of those ">>" for the code to work)

just does not add the target "Alltogether.txt" to it,  so copy /b (to avoid any linefeed or special character) to the same folder is just fine. Because it check all the files in the folder, then adds them to another...typical batch...if, wouldn't that lead to an infinite loop? ;-)
But you are right anyway. I would pipe the output to a different folder as well. Just in case.

Thomas I edited it, sorry for typo
nah, no worries...If I would get a penny for all my batch mistakes...I would be a rich man... :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial