Back to blog

How to Create a .BAT File Using Online Notepad

Jul 3, 20262 min read

A .bat file is a small script that runs a set of commands on Windows automatically. You don't need any special software to write one. Notepad is enough.

What is a .BAT file?

BAT stands for batch. A batch file holds a list of commands that Windows runs in order when you double-click it, the same commands you'd type into Command Prompt one at a time. It's a fast way to automate repetitive tasks like opening programs, copying files, or running a series of scripts.

Step-by-step: Create a .BAT file in Notepad

Step 1: Open Notepad

Open Notepad on Windows, or write your script in a free online notepad first and paste it in later.

Step 2: Start with @echo off

Add this line at the top of your file:

@echo off

This stops Windows from displaying every command as it runs, so you only see the actual output.

Step 3: Write your commands

Add each command on its own line. Here's a simple example that creates a folder and opens Notepad:

@echo off
echo Creating folder...
mkdir MyFolder
echo Done!
pause
Step 4: Save with a .bat extension

Go to File, then Save As. Choose All Files in the "Save as type" dropdown. Name the file with a .bat extension, for example setup.bat. Without this step, Windows saves it as a .txt file, and it won't run as a script.

Step 5: Run the file

Double-click the .bat file to run it. A black Command Prompt window opens and runs each line in order.

Common commands used in batch files

  • echo displays text on the screen.

  • pause stops the script and waits for a key press, useful for reading output before the window closes.

  • mkdir creates a new folder.

  • del deletes a file.

  • cd changes the current directory.

  • cls clears the screen.

  • start opens a program or file.

Conclusion

A .bat file is nothing more than a list of commands saved as a script. Write your commands in Notepad, save the file with a .bat extension, and double-click to run it. Start with something simple like opening a folder, then build up from there once you're comfortable.

Related posts