Batch Programming
Batch programming is a programming paradigm that can execute certain commands automatically at the level of an operating system such as DOS or Windows 7 / XP. A batch file is a stack of such commands. If it is retrieved with the command line, the system will execute each task listed in succession. Therefore, the term batch processing is quite common. Batch files are often used to control and configure operating systems, but can also be used for other operations such as server installations. The most famous is probably the Autoexec.bat file that starts the DOS operating system.
History
In the early days of information technology programs and records were stored on punch cards which were then successively added to the computer. This batch was the sequence in which the system had to work. Both data and commands could be input into the system that way. With the advent of other storage media such as magnetic cards and tapes in the sixties, punch cards were supplanted more and more, but the term batch processing was still applied to the principle of successive, sequential processing.
Functionality
Batch programming can be classified as an interpreter-based scripting language. It includes fundamental functions of a programming language, such as IF, IF NOT, or WHILE, but you cannot program applications with it. Since programs with numerous commands are not saved after compilation as an executable file, as is common in applications, batch files rely on a time-oriented translation into machine language. This is done through the Windows command line cmd.exe (under DOS command.com). The batch file, which can be edited with a standard text editor, gets and parses what is there and translates it into binary code.[1]
The command line can only run the file if it is formulated in the correct batch syntax, in other words, the available characters, commands and their links need to be within the batch grammar of the respective system. To illustrate: some batch commands for MS-DOS may not be available under certain circumstances in Windows NT or Windows 7.[2]
Frequently used, basic batch commands are:
echo
- Displays text on the screen
@echo off
- Prevents the output of text
rem
- Sets a comment line
start
- Runs a file in its default application
mkdir
- Creates a folder
rmdir
- Removes a folder
del
- Delete one (or more) file(s)
copy
- Copies one (or more) file(s)
xcopy
- Copying a file with additional options
for in do
- For a variable X (for) a value (in) is assigned, and then an action (do) will be initiated. Thus you can, for example, delete all files with a certain file extension in the current directory.
call
- Gets a batch file within the current one
if
- Under a certain condition, an action is performed. “Else” must be noted for an alternative if the condition doesn’t apply.
When recording the commands, spaces can lead to program crashes. If spaces occur in file names, they must be enclosed in quotes. Batch files also cannot read any special characters like ä, ö or ü. They are restricted to the ASCII character set that does not include umlauts. Caution is advised for a lot of commands because certain files are essential for the functioning of the system. Batch programmers should know exactly what they are doing in order not to jeopardize the stability of the system.
Example
A simple example of the text output of “Hello World!” is the Hello.bat file. It is written with a text editor, saved and then called up with the command line and run. The text “Hello World!” appears in the command line. The lines that are marked with REM (comments) explain the preceding batch commands and will not be executed.
echo Hello World! REM text "Hello World!" output. pause REM Only once a button is pressed will the program close.
Importance for online marketing
In principle, batch programming can be used for individual tasks in the field of online marketing. IP addresses and images can be processed in batches. Batch jobs are always suitable for tasks where many steps of the same kind need to be executed in sequence. For example, batch programming is sometimes used for reading log files, to extract data for web analytics, save it, and print it. However, other programs are usually preferred because the amount of programming needed would be very high.
References
- ↑ How does the Windows Command Interpreter (CMD.EXE) parse scripts? stackoverflow.com. Accessed on 03/05/2015
- ↑ Batch Files & Batch Commands robvanderwoude.com. Accessed on 03/05/2015