File Formats Wiki

Batch file

261pages on
this wiki
Add New Page
Talk0 Share
Batch file

Filename extension .bat, .cmd, .btm
Type Scripting
Opens with Windows Shell
any text editor
File formats category - v  e   edit

A batch file is a text file containing lines of commands to be executed by the command-line interpreter.



Batch files also implement syntax common to programming.

if: conditional statement

  • if String1 == String2 Command - tests if the strings are equal, and executes the command
  • if errorlevel Number Command - tests if a previous command executed returned an exit code greater than or equal to that the specified number.
  • if exist Filename - tests if the file with the specified filename exists.

A not can be used after the if to check instead if the condition is false. An else can be attached to the end to indicate a command to be executed if the first condition was not performed (that is, if the condition is false, or, when not is used, true).

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.