Learning Resources
 

Introduction to simple batch files

Batch files have ‘BAT’ as extension and has commands which are executed one-by-one.

 

In DOS, OS/2, and Microsoft Windows, batch file is the name given to a type of script file, a text file containing a series of commands to be executed by the command interpreter.

The commands may be built into the command processor (COPY), supplied with the operating system but not built into it (XCOPY invokes the Microsoft DOS program XCOPY.EXE), or may be any program (cp invokes the program cp.exe if present, an .EXE port of the Unix cp command, with essentially the same functionality as XCOPY.EXE).

Similar to job control language and other systems on mainframe and minicomputer systems, batch files were added to ease the work required for certain regular tasks by allowing the user to set up a script to automate them. When a batch file is run, the shell program (usually COMMAND.COM or cmd.exe) reads the file and executes its commands, normally line-by-line. Unix-like operating systems (such as Linux) have a similar type of file called a shell script.

The filename extension .bat was used in DOS, and the Windows 9x family of operating systems. The Microsoft Windows NT-family of operating systems and OS/2 added .cmd. Batch files for other environments may have different extensions, e.g. .btm in 4DOS and 4NT related shells.

There have been changes to the detailed handling of batch files; some of the detail in this article is applicable to all batch files, while other details apply only to certain versions.

--wikipedia