How to Write a Batch File
A batch file contains a series of DOS commands, and is commonly written to automate frequently performed tasks.A batch file may contain any command the interpreter accepts interactively at the command prompt. A batch file may also have constructs (IF, GOTO, Labels, CALL, etc.) that enable conditional branching and looping within the batch file.
.bat: The first filename extension used by Microsoft for batch files. This extension runs with MS-DOS and all versions of Windows, under COMMAND.COM or cmd.exe, despite the different ways the two command interpreters execute batch files.
Writing a batch file is easier than it looks; the difficult part is making sure that everything happens in the right order. Well-made batch files can save you a lot of time over the long run, especially if you deal in repetitive tasks.
Batch files run a series of DOS commands, so the commands that you can use are similar to DOS commands. Some of the more important ones include:
ECHO - Displays text on the screen
@ECHO OFF - Hides the text that is normally output
START - Run a file with it's default application
REM - Inserts a comment line in the program
MKDIR/RMDIR - Create and remove directories
DEL - Deletes a file or files
COPY - Copy a file or files
XCOPY - Allows you to copy files with extra options
FOR/IN/DO - This command lets you specify files
steps to make a bat file
@echo off cls :start echo This is a loop set choice= set /p choice="Do you want to restart? Press 'y' and enter for Yes: " if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='y' goto start