We help IT Professionals succeed at work.

Join several text files into one

116 Views
Last Modified: 2018-10-26
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..
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

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


»bp
aravind ancheWindows/Vmware
CERTIFIED EXPERT

Commented:
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
CERTIFIED EXPERT

Commented:
@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.
aravind ancheWindows/Vmware
CERTIFIED EXPERT

Commented:
Thomas I edited it, sorry for typo
CERTIFIED EXPERT

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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions