The problem you're seeing is due to delayed expansion, where when you're operating in a loop like this the variables %date% and %time% are determined at the start, and don't update as the script loop runs. You can see that if you echo out your query to screen :
for /l %%x in (1, 1, 35000) do echo %date% %time%
You'll see the time never changes.
The fix is to enable delayed expansion, and also bracket the loop code (looks like delayed expansion doesn't work otherwise), and finally replace the % variable characters with ! which tells the system they should be re-evaluated each time the loop runs. Tested, and I think this should do the job you're after :
setlocal ENABLEDELAYEDEXPANSION
cd C:\temp
echo Start > dummy.txt
for /l %%x in (1, 1, 35000) do (
echo !date! !time! >> C:\temp\dummy.txt
)
set longHour=%time:~0,2%
set hour=%longHour: =0%
COPY dummy.txt %date:~-4,4%%date:~-10,2%%date:~-7,2%-%hour%%time:~3,2%%time:~6,2%.txt
echo End >> dummy.txt
Note, the other issue I spotted is that time:~0,2 only works as you'd expect when you have 2 digit hours (I'd not have noticed if I hadn't happened to try it before 10am!), so for example after 10am it might generate :
20232904-101735.txt
but before 10am you'd end up with :
20232904- 95935.txt
with a space between the - and 9, so I've also gotten it to replace that space with a 0 if one is found, so you end up with :
20232904-095935.txt