I am writing a Batch file that traverses through an entire directory (including all sub-directories) and prints checksum of each file it finds into a checksum.txt text file.
It seems that both ECHO statements which I've made bold return null values of the variables count and var. Eventually this means that the resulting checksum.txt file that is created is empty.
setlocal ENABLEDELAYEDEXPANSION
For /R "C:\Users\MyName\Desktop\SourceDir" %%G in (*) do (
SET /A count=1
FOR /F "tokens=* USEBACKQ" %%F IN (`certutil -hashfile "%%G" sha256`) DO (
SET var!count!=%%F
SET /A count=!count!+1
echo ****************************************** %count% %var1%
)
echo ****************************************** %var1%
SET FILECHECKSUM=%var1% %var2%
>>"CHECKSUM.TXT" echo(%FILECHECKSUM%
)
timeout /t -1