Bat File Introduction
Intro to Bat files for automation
What it is?
- It’s a text file with
*.bat
extension. you can open bat file usingNotepad
- It contains windows commands which we can run without user intervention
How to open bat files
- Bat files are simple text files so you can directly open it via
Notepad
- To open the BAT file in Notepad, right-click it and choose Show more options > Edit from the menu
How to create new bat file
- you create new text file in notepad with commands for bat file
- while saving that text file change file extension from
*.txt
to*.bat
How to use it?
- bat files are supported by windows out of box, so you don’t need any special program to run it
- Just double click on bat file to run its commands
While bat files are not inherently dangerous, they can be used maliciously. for example, script can delete some files or move files without your knowledge. so always review the contents of bat file before running it on your computer, especially when you get bat file from untrusted source.
Some basic use cases of bat files
- Running bat file to clean up extra files generated by FEM programs
- Running bat file to run multiple programs in sequence
- Create new folders
- Hide folders
- basically, any task you can do via
Command Prompt
, you can automate it via bat file
Sample Bat commands
del filepath
: deletesfile
file using given file pathdel file.txt
: deletesfile.txt
file in active folderdel *.txt
: deletes all files with*.txt
extensions
This post is licensed under CC BY-NC-ND 4.0 by the author.