Development

What is a batch file

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.

Quick

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
Hello world

If you opened command prompt (CMD) and typed @echo Hello world then pressed enter you would get the same result.

Usage

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.

 

 

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago