V
V
vladislavik952017-06-23 00:09:07
cmd/bat
vladislavik95, 2017-06-23 00:09:07

How to merge txt files into one?

I watched a video on how to solve this problem. Super, it does what it needs to do, but for some reason it does the same files twice. That is, the same text is obtained 2 times in one file. How did I merge the files? I created a simple txt file, wrote the code
cd . >output.txt
FOR %%f IN (*.txt) DO Type "%%f" >>output.txt
And renamed this file to file.bin..... That's it. The question is - - - why does it do its job 2 times and how to fix it?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2017-06-23
@res2001

Perhaps because your output.txt also falls under the *.txt mask and it is added to itself.
This is an assumption, but, in my opinion, it seems to be true. To check, just use the same file.bin instead of output.txt - it will no longer match the mask and will not be added to itself.
In general, your task is solved much easier:
copy *.txt file.bin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question