|Now, consider the following instructions
copy \dos\*.exe \newdir
|Executing commands at DOS prompt:
|Normally, we can execute only one MS-DOS command at one time (except we use a “trick”). We cannot give another instruction before DOS has done our current command.
|If we manually instruct DOS to execute the above commands, we have to type each command at theDOS prompt one after another.
|Executing commands in a batch file:
|However, if we put all of the commands in a text file in the same manner as in the above box, it becomes an executable program.
|Let’s name it anyname.bat Similar to a COM or EXE command, we can simply type the name of this batch file at the DOS prompt to start our instructions.
|i.e. C:\>anyname or C:\>anyname.bat (note: the extension bat is optional here. It makes no difference, no matter we put it or not.)
|DOS will then execute the commands automatically in the same order as written in the anyname.bat The followings are details of what DOS will do for us:-
|1. Creates a new directory under the root called newdir
|2. Copies all files under the DOS directory with an extension of EXE to the newly created newdir directory.
|3. Changes the current directory to newdir directory
|4. Display the directory listing of newdir directory
|5. Changes the current directory to root directory