Here, the list is the values for which for loop will be executed. Here in this program, we have 1, 2 and 3 in the list. So, for every element of the list the for loop will be executed and following output is generated. In batch file programming, for loop can also be implemented through a range of values. Following is the syntax for implementing for loop through a range of values in the batch file. DOS Batch is the Windows equivalent of shell scripting and can be used to perform all sorts of different actions.
Anything that you type into a DOS prompt on a Windows machine can be used in a bat file to quickly do something that you would otherwise have to repeat many times over.
To create a bat file just make a file and give it the extension "bat". If you run a DOS prompt and navigate to the directory that the bat file exists in you can type the name of the file to get it to do certain actions.
If you called your file "action. Starting with a simple example, if you want to print the contents of a file to screen then you need the type command, followed by the file. However, this puts a lot of rubbish on the screen.
If you wanted to create a backup of that file then you would write the following. This takes the contents of one file and puts it in another. In this example, I'm going to use two 2 batch files, but in your real world solution, the second batch file might be an executable. So we'll create our first DOS batch file dubbed " doit. This set command returns a bare directory listing no filesize, attributes, etc.
You could also include the full directory path here, just in case this DOS batch file isn't located in the same directory as your txt files. Finally we do a "do call" to tell the program to call our second batch file runner.
0コメント