I am new at batch programming. I want to save multiple values in a text file with the same variable. To be more clear here is my code:
@echo off
cls
set /a "num=0"
:start
echo %num%
set /a "num=num+1"
echo %num% > text.txt
goto start
What I need is that every time the number gets bigger and saved, the smaller numbers will remain saved. For example, now when %num% becomes "3", the number 3 will be saved in the text.txt file, but it will replace the previous number. Is there any solution?
Use the '>>' operator instead of '>'.