Business Courses / Course / Chapter

How to Create a Batch File

Instructor: Lonny Meinecke

Lonny was once a software programmer (video game industry). He now teaches psychology at King University. He has a bachelor's in IT and a PhD in psychology.

This lesson will explain how to create a batch file. It will also provide some background on what a batch file is, what it's used for, and provide a simple example.

What is a Batch File?

Unless you grew up in the days before the Windows operating system, you may not have heard of a batch file. So, what is a batch file anyway?

Simply put, a batch file is a simple text file that acts more like a computer program than a text document. These files are usually named so they end with the file extension .bat. That's important, because the operating system uses that file extension to figure out if this is a batch file. For example, if you name it batch.bat, the computer will execute it as a batch file. But if you name it batch.txt, the computer will open it in text mode instead.

What Does a Batch File Do?

A batch file automates computer tasks for you, so you don't have to type in the instructions every time. Where do you type in instructions in Windows, you ask? Good question. You normally type the instructions in something called the Windows Command Prompt (it's a little black window that lets you type text instructions in it). Super users know how to do amazing tricks with a computer - often using a Command Prompt. If you've ever had a tech clean your temporary folders, for instance, he or she probably used a Command Prompt to type stuff in and clean everything in your temporary folders to make your system run faster. The same tech may even have used a batch file to avoid typing in all those commands.

Here's an example of the Command Prompt in Windows 10:

The Windows 10 Command Prompt
command prompt

How Do I Create a Batch File?

The easiest way to create a batch file is to perform the following steps:

  • Right click on your computer desktop
  • In the context menu that pops up, choose New, then choose Text Document
  • Rename the new file as name.bat (but insert your desired name where 'name' is)

Important: Windows automatically adds the file extension .txt, so make sure you change it to .bat. Windows will warn you not to change the file extension, but you can ignore that. Now you can edit this like any old text file. Since the file extension isn't .txt though, you will need to right click it each time, and choose Edit whenever you want to edit the text in your batch file. Otherwise, if you double click it (or right click it and choose Open), it will execute as a batch file (more like a program) instead of letting you edit it.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back

Resources created by teachers for teachers

Over 30,000 video lessons & teaching resources‐all in one place.
Video lessons
Quizzes & Worksheets
Classroom Integration
Lesson Plans

I would definitely recommend to my colleagues. It’s like a teacher waved a magic wand and did the work for me. I feel like it’s a lifeline.

Jennifer B.
Jennifer B.
Create an account to start this course today
Used by over 30 million students worldwide
Create an account