Roy of Superior Art Creations archive
Date : October 25, 2009

thumb

Some Handy MS DOS Batch Tricks – Infinite Loop and Wait Command

Categories: Tools
Tags: No Tags
Comments: 5 Comments
Published on: October 25, 2009
I am always interested in how to do stuff with Windows command line tools and BATCH scripts to make things easier and to automate processes that are related to the operating system itself or to the file system. I found some interesting tricks and tips in one of the recent issues of my favorite computer magazine from Germany called “CT Magazin” (CT stands for “Computer Technik”) by the publisher “Heise” (which I am still subscribed to here in the United States). I’d like to share those with you, but written in English language. I also included some additional tips and practical examples for using the tricks. Infinite Loop The obvious method to do an infinite loop within a BATCH script is the use of “LABELS” and a “GOTO” command within it that jumps to the same label address e.g. 1: :MYLABEL 2: … commands to execute here … 3: GOTO :MYLABEL However, this code might ends up to be harder to read and it has the short-coming that it cannot be used from the command line directly and only from within a .BAT Batch script. But there is another way to create an infinite loop via BATCH commands. 1: for /L %i in (0,0,0) do SINGLE-COMMAND or if you want to execute a list of commands within the loop: 1: for /L %i in (0,0,0) do ( 2: … multiple commands here … 3: ) where you have to replace “SINGLE-COMMAND” with your own command call or “… multiple commands[…]
Welcome , today is Thursday, June 21, 2018