Skip to content
rbaltrusch edited this page Feb 15, 2021 · 6 revisions

Welcome to the batch wiki!

This wiki documents common batch workflows, both for scripting in the shell and batchfiles, by detailing the most important features of the batch language, as well as some intricacies of the language which are important to keep in mind.

What is Batch?

Batch is a weakly-typed, case-insensitive, dynamic runtime shell scripting language for the Windows command-line (shell). It contains tools to list and manipulate file and folder contents and makes it easy to access or change Windows environment, such as the path or other system information.

An example of the concise way Batch writes some text to a file might be the following example, which writes hello world to a new file called text.txt:

echo hello world>text.txt

Beyond system manipulation, the language is extremely limited and often needs unusual roundabout methods to accomplish simple tasks. For example, to compute the length of a string, one might write the following unusual code:

set "string=hello world"
echo %string%>temp.txt
for /f %%f in ("temp.txt") do ( set /a length=%%~zf - 2 )
del temp.txt
echo length of string is %length%

A detailed description of the code snippet above can be found here.

With this short overview of the good and the bad, batch scripting establishes itself as a very helpful tool on Windows systems for developers, which may help speed up repetitive tasks significantly, or simply ease one's traversal through the command line to access various other utilities, such as git and pip. Functionality beyond this rarely lends itself well to the Batch language.

Clone this wiki locally