Windows batch echo countdown












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.










share|improve this question






















  • you would need delayedexpansion
    – Gerhard Barnard
    Nov 12 '18 at 14:07










  • delayed expansion
    – 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














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.










share|improve this question






















  • you would need delayedexpansion
    – Gerhard Barnard
    Nov 12 '18 at 14:07










  • delayed expansion
    – 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












0








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.










share|improve this question













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.







batch-file for-loop variables count command






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 13:58









Jeff

1551313




1551313












  • you would need delayedexpansion
    – Gerhard Barnard
    Nov 12 '18 at 14:07










  • delayed expansion
    – 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


















  • you would need delayedexpansion
    – Gerhard Barnard
    Nov 12 '18 at 14:07










  • delayed expansion
    – 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
















you would need delayedexpansion
– Gerhard Barnard
Nov 12 '18 at 14:07




you would need delayedexpansion
– Gerhard Barnard
Nov 12 '18 at 14:07












delayed expansion
– Stephan
Nov 12 '18 at 14:21




delayed expansion
– Stephan
Nov 12 '18 at 14:21




3




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






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




@Stephan - The latter works perfectly. Thanks!
– Jeff
Nov 12 '18 at 14:41












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263717%2fwindows-batch-echo-countdown%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263717%2fwindows-batch-echo-countdown%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues