0

I have a script with a for loop that works but I would like to change the echoed line so that it includes the number of retries remaining.

Below is my latest attempt but I cannot get it to show the number of retries:

rem Will loop 20 times with 30 second intervals (Total 10 minutes) to confirm deletion. Loop will exit after 20 attempts and move on if dll cannot be deleted.
for /l %%i in (1,1,20) do (
set /a "count=20-=%%i"
del /f /q "%Folder2Del%file*.dll" >nul
if not exist "%Folder2Del%file*.dll" goto Folder2Del
echo/
echo File locked! Will try to delete %count% more times before exit.
timeout /t 30 >nul
)

I've searched and tried to apply many examples but I just can't get it working. I don't know how to properly set my 'count' variable.

Jeff
  • 495
  • 1
  • 5
  • 18
  • you would need `delayedexpansion` – Gerhard Nov 12 '18 at 14:07
  • [delayed expansion](https://stackoverflow.com/a/30284028/2152082) – Stephan Nov 12 '18 at 14:21
  • 3
    and `set /a "count=20-=%%i"` is wrong. It should read `set /a count=20-%%i`. alternatively you could `for /l %%i in (20,-1,1) do (` and just `echo ...try to delete %%i more times...` (no need for the `count` variable, so also no need for delayed expansion) – Stephan Nov 12 '18 at 14:24
  • @Stephan - The latter works perfectly. Thanks! – Jeff Nov 12 '18 at 14:41

0 Answers0