I want to use echo to add data into a text file progressively. I wrote a small batch code as follows:
@echo off
echo >text.txt
set DllCopier_d=./DllCopier
echo %DATE:~04%>text.txt
echo %TIME:~0,5%>text.txt
echo %~dp0%>text.txt
When I look at text.txt at the end, i found only one line:
C:\omsstest_automation\win32\
Which is result of last line.
Why is the “echo” resulting into replacing previous contents of text.txt?
>means create a new file with these contents (replace the old if it exists),>>means append or create a new file if none already exists.So to spell out the answer to your question, replace subsequent usages of
>after the very first one with>>.