if exist d:\test1\tmp\origin.txt. (del d:\test1\tmp\origin.txt.)
for /r d:\test1\tmp\ %%i in (*.txt) do (
type %%i >>d:\test1\tmp\origin.txt
@echo merging with %%i
)
that is because you created origin.txt in the directory where your code is searching for all txt files. Try substitute the following lines for your code.
if exist d:\test1\tmp\origin.txt. (del d:\test1\tmp\origin.txt.)