Baby Names
From Avery to Zephyr, Nameberry is the complete guide to thousands of amazing baby names.

Here you’ll find the world’s biggest baby name database, the most creative lists of names for girls and boys, the friendliest forums, and the best ideas and expert advice on naming your baby in 2020.
Baby Name News
if
- 3 minutes to read
- +1
Performs conditional processing in batch programs.
Syntax
if [not] ERRORLEVEL <number> <command> [else <expression>]if [not] <string1>==<string2> <command> [else <expression>]if [not] exist <filename> <command> [else <expression>]
If command extensions are enabled, use the following syntax:
if [/i] <string1> <compareop> <string2> <command> [else <expression>]if cmdextversion <number> <command> [else <expression>]if defined <variable> <command> [else <expression>]
Parameters
Parameter | Description |
---|---|
not | Specifies that the command should be carried out only if the condition is false. |
errorlevel <number> | Specifies a true condition only if the previous program run by Cmd.exe returned an exit code equal to or greater than number. |
<command> | Specifies the command that should be carried out if the preceding condition is met. |
<string1>==<string2> | Specifies a true condition only if string1 and string2 are the same. These values can be literal strings or batch variables (for example, %1 ). You do not need to enclose literal strings in quotation marks. |
exist <filename> | Specifies a true condition if the specified file name exists. |
<compareop> | Specifies a three-letter comparison operator, including:
|
/i | Forces string comparisons to ignore case. You can use /i on the string1==string2 form of if. These comparisons are generic, in that if both string1 and string2 are comprised of numeric digits only, the strings are converted to numbers and a numeric comparison is performed. |
cmdextversion <number> | Specifies a true condition only if the internal version number associated with the command extensions feature of Cmd.exe is equal to or greater than the number specified. The first version is 1. It increases by increments of one when significant enhancements are added to the command extensions. The cmdextversion conditional is never true when command extensions are disabled (by default, command extensions are enabled). |
defined <variable> | Specifies a true condition if variable is defined. |
<expression> | Specifies a command-line command and any parameters to be passed to the command in an else clause. |
/? | Displays help at the command prompt. |
Remarks
If the condition specified in an if clause is true, the command that follows the condition is carried out. If the condition is false, the command in the if clause is ignored and the command executes any command that is specified in the else clause.
When a program stops, it returns an exit code. To use exit codes as conditions, use the errorlevel parameter.
If you use defined, the following three variables are added to the environment: %errorlevel%, %cmdcmdline%, and %cmdextversion%.
%errorlevel%: Expands into a string representation of the current value of the ERRORLEVEL environment variable. This variable assumes that there isn't already an existing environment variable with the name ERRORLEVEL. If there is, you'll get that ERRORLEVEL value instead.
%cmdcmdline%: Expands into the original command line that was passed to Cmd.exe prior to any processing by Cmd.exe. This assumes that there isn't already an existing environment variable with the name CMDCMDLINE. If there is, you'll get that CMDCMDLINE value instead.
%cmdextversion%: Expands into the string representation of the current value of cmdextversion. This assumes that there isn't already an existing environment variable with the name CMDEXTVERSION. If there is, you'll get that CMDEXTVERSION value instead.
You must use the else clause on the same line as the command after the if.
Examples
To display the message Cannot find data file if the file Product.dat cannot be found, type:
if not exist product.dat echo Cannot find data file
To format a disk in drive A and display an error message if an error occurs during the formatting process, type the following lines in a batch file:
:begin@echo offformat a: /sif not errorlevel 1 goto endecho An error occurred during formatting.:endecho End of batch program.
To delete the file Product.dat from the current directory or display a message if Product.dat is not found, type the following lines in a batch file:
IF EXIST Product.dat (del Product.dat) ELSE (echo The Product.dat file is missing.)
Note
These lines can be combined into a single line as follows:
IF EXIST Product.dat (del Product.dat) ELSE (echo The Product.dat file is missing.)
To echo the value of the ERRORLEVEL environment variable after running a batch file, type the following lines in the batch file:
goto answer%errorlevel%:answer1echo The program returned error level 1goto end:answer0echo The program returned error level 0goto end:endecho Done!
To go to the okay label if the value of the ERRORLEVEL environment variable is less than or equal to 1, type:
if %errorlevel% LEQ 1 goto okay
Additional References
Is this page helpful?
Thank you.
Feedback
Submit and view feedback for
Is this page helpful?
Thank you.
Top Pages on Nameberry
Browse Unique Baby Names
Unique names are becoming more fashionable for both baby girls and baby boys, with more rare and uncommon names appearing all the time. Find unique nature names and word names, international names, and ancient names that are back in use for the first time in centuries.
Join the Conversation
Talk baby names on our forums with your fellow Berries.
- Why I love X
- What would you name all boy triplets?
- Twin girls!
- How many Hazels do you know?
- Ruby…?
- Vote for Violet & Hugo’s brother’s name!
- Help me get to Winnie and Nell
- I need new girl names… nothing seems perfect
- Sonora or Scarlett
- Little brother for Julia and Claire?
- Go to the forums
Browse Names by Style
Top 1000 Names on Nameberry
Baby name popularity changes fast. That's why we update our popularity lists in real time, so you can see which baby names rank highest with Nameberry readers right now. For 2020, we see more unique baby names for boys and girls rising to the top of the list, along with classic names and vintage names back in style.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
Search Baby Names by Origin
Most Popular Names 2020
The SSA list of popular baby names has been changing more in recent years than ever before. Most of the names that were popular when this generation of parents were born -- Jessica and Joshua, Ashley and Christopher -- have sailed away, to be replaced by new Number 1 baby names like Emma and Liam, along with unique names undiscovered a generation ago, from Luna to Bodhi.
Top girl names in the US include classics Olivia and Charlotte, with unique choices such as Octavia, Lyra, and Oakley among the fastest-rising names for girls. For boys, the top-ranking names include the Biblical Noah and the classic boy names William and James. Boy names climbing the popularity list fastest include Caspian (as in the sea), Otter (as in the animal), and Nova (as in the star).
Nameberry is the leader in analyzing baby name popularity, tracking trends, and discovering new names. Created by internationally-recognized name experts Pamela Redmond Satran and Linda Rosenkrantz, it’s the largest and most complete baby name resource in the world. We have everything you need to find the name that’s perfect for you and your baby.