HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to MS-DOS BatchVariablesConditions (IF)Loops (FOR)File OperationsParameters and Subroutines
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔀 Condition
if / else
🔁 Loop
⚙️ Commands & Flow
MS-DOS›REFERENCE›Condition
🔀

Condition

Decision making with if.

CommandDescription
if / elseRuns a command based on a condition.

if / else

Try it yourself →

Runs a command based on a condition.

Syntax

if condition (...) else (...)

Description

Comparison: == (equal), equ gtr lss (numeric). if exist checks if a file exists, if errorlevel checks error codes.

Example

@echo off
set /a x=7
if %x% gtr 5 (echo greater) else (echo smaller)

Expected output

greater

When to use?

Flow branching.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code