Direct a batch program to jump to a labelled line.
syntax GOTO label
label : a predefined label in the batch program. Each label must be on a line by itself, beginning with a colon.
IF %1==12 GOTO s_december
:: other commands
An easy way to exit a batch script file without defining a label is to specify
this transfers control to the end of the current batch file.
Using a variable as a label
echo You typed Y for yes
echo You typed N for no
Skipping commands by using a variable as an optional :: (REM) comment
In this example the 2 COPY commands will only run if the parameter "Update_Now" is supplied to the batch
IF [%1]== GOTO :eof
IF /I NOT %1==Update_Now SET v_skip=::
%v_skip% COPY x:\update.dat
echo Your WWW connection is up to date
%v_skip% COPY x:\FTP.dat
echo Your FTP connection is up to date
If Command Extensions are disabled GOTO will no longer recognise the :EOF label
Equivalent Linux BASH commands:
case - Conditionally perform a command