Avatar of E=mc2
E=mc2
Flag for Canada asked on

Join several text files into one

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..
Windows 10Windows BatchScripting Languages

Avatar of undefined
Last Comment
Thomas U

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Thomas U

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

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


»bp
aravind anche

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
Thomas U

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

@Bill.
just tested...it 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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
aravind anche

Thomas I edited it, sorry for typo
Thomas U

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