.bat and .cmd files are more or less the same thing
nowadays
Use the @ symbol to prevent a line from
writing to standard output
echo off turns off the printout for
every subsequent command
SETLOCAL is a scope boundary
ENDLOCALBy default all loops parse at once at load time
EnableDelayedExpansion: Allows us to
read variables dynamically as they update
!VAR! for an updating
variable%VAR% for a non-updating oneDefine variables with SET But be
careful about quotes
SET VAR = "VAL" will interpret the
value as \s"VAL" (ie. it includes the
leading space and the quotations)SET VAR = VAL\s (with a trailing
space) will include that space as part of the valueSET "VAR=VAL" is best practiceFOR /L %%i IN (0,1,2) DO (
SET "REPO=!REPOS[%%i]!"
...
)The exclamation points say that the variable is updating throughout
the loop. /L is a flag that says we're
using an explicit numeric counter (0,1,2) denotes
%1 represents the first command-line
argument passed to the batch script
%~1 strips any quotation marks placed
around the command by the VBS caller
if errorlevel X: checks if the
preceding command's return code is ≥ X