A batch file is a pre-written script that when double-clicked executes its contents within the command prompt. The idea behind a batch script is to save time and avoid repeting commands as putting the code into a batch file and executing it is the same as directly putting it into the command prompt and running it there.
Batch files allow the use of loops and conditional (if) statements. They also can be called from within the command prompt.
The language is called DOS and for a quick example save the following as a .bat and double click it:
@echo Hello world. @pause
If you opened command prompt (CMD) and typed @echo Hello world then pressed enter you would get the same result.
As stated above batch files prevent retyping commands, using batch files to run complex or hard to remember commands like FFmpeg, youtube-dl, server start ups, monitoring and more is an efficient method.
A batch file can be seen somewhat similar to a function, you write them out once and use configurable values to reuse. You dont need to retype out the whole command, even better if you use variables so your command can easily be addapted.
Here is a batch file that starts and then restarts a Dayz Server based on a loop and timing.
CMD commands are in the plenty, See the full list of commands here.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…