Batch Scripts on Windows 10: Making Life Easier
Batch scripts are a set of commands written in a file that are executed one after another to automate tasks. These scripts help make it easier for users to run multiple commands in the Command Prompt without having to type each one manually. Batch scripts are especially useful if you often need to run more than just a couple of commands or want to save time in your daily routines.

Basics of Batch Script
In a batch script, you mostly use commands that also work in the Command Prompt. Some commands are basic, such as those for printing text, pausing the script, or closing the window, while others serve specific purposes, such as checking ping or viewing network statistics. Instead of opening the Command Prompt every time and typing the commands yourself, you can simply create a batch script file and run it whenever needed.
There are many commands you can use in your batch scripts, but here are a few of the most basic:
- ECHO – Displays text in the Command Prompt window.
- @ECHO OFF – Hides the command display and only shows messages on a clean line.
- TITLE – Changes the title of the Command Prompt window.
- PAUSE – Stops the Command Prompt window from closing automatically after the script finishes running.
Note: Make sure the name of your batch file is different from any default system files to avoid conflicts. You can also use the ‘.cmd’ extension; however, earlier versions of Windows may not support it.
Writing Simple Batch Scripts
To get started, you can write a simple batch script to understand how commands work. Just like in other programming languages, the first thing you often do is print text. Here, you’ll use the ECHO command to print a simple message. Follow these steps to create your first batch script file:
- Hold the Windows key and press S to open the search function. Type ‘notepad‘ and press Enter to open Notepad.
Opening Notepad through the Search function - Using the basic commands listed above, write the following simple batch script in Notepad:
@ECHO OFF :: This is a comment that you can write in a batch script. TITLE APPUALS :: Title is the name for the CMD window. ECHO Hello Appuals Users, this is a simple batch script. PAUSE
- Click File in the top menu, choose Save As, set a file name, and change the extension to ‘.bat‘. Click the Save button.
Saving the file with ‘.bat’ extension. - Double-click the saved file to run your batch script.
Writing Different Batch Scripts for Different Purposes
Below are a few examples to demonstrate how batch scripts work in different scenarios. The method for creating the script is the same as shown earlier—simply replace the code in Notepad with one of these examples, then save and run your batch file.
1. Copy or Move Files Using a Batch Script
You can use a batch script to copy files from one location to another. For example, this can be handy if you often need to copy or move photos from your phone or camera SD card to your computer. If you regularly use the same source (like a USB or SD card), this batch file saves you from manually selecting files every time. By setting the source and destination, you can simply run the script to copy or move files.
- Create a new text file and add the following code:
xcopy "E:\New Folder\*.apk" "D:\My Folder\"
Writing code for copying files. Note: The first path is the source, and the second path is the destination. To copy all files from the source folder, remove the ‘.apk‘ extension and it will copy everything in the folder.
- Save the file with the ‘.bat‘ extension and run it.
File copied by using a batch script.
Note: To move files instead of copying, change ‘xcopy‘ to ‘move‘ in your script.
2. Change the File Extensions in a Folder
You can create a batch file that changes the extensions of all files in a given folder. Extensions can be changed within similar file formats—for example, changing JPG files to PNG—or you can change the file type completely. If you wrote batch script code in a text file, you can change the file extension from .txt to .bat using this script:
- Create a new text file and open it in Notepad. Write the following code:
@ECHO OFF ren *.txt *.png
- Save it with the ‘.bat‘ extension and double-click the file to run it.
Changing the extension of files.
3. Check Ping for Two Different Sites Using a Single Line Command in a Batch Script
This example shows how to use more than one command in a batch script. It’s helpful if you want to run a set of useful commands one after another to reach a certain goal. Here’s how you can check the ping of two different websites with one line:
- First, create a new text file and write the following code:
@ECHO OFF TITLE CHECKING PING ping www.google.com && ping www.appuals.com PAUSE
Note: You can also write each command on a separate line. The ‘&&‘ in this code means that the second command will only run if the first command completes successfully. If you use just a single ‘&‘, both commands will run regardless of whether one fails.
- Save it with the ‘.bat‘ extension and open it.
Checking ping by using the batch file. Note: You can add any website URL instead of the ones in the example.
These are just a few of the many things you can do with batch scripts by following some basic rules and using different commands. Experiment with the above examples, and you’ll soon get the hang of automating tasks using batch files!