Input argument of batch script

%0 :: script name
%1 :: direct reference argument
..
%9 :: direct reference argument

variable scope

SETLOCAL
REM 
ENDLOCAL

string

rem comparing string
if [%str%]==[]
rem string variable must be in []
rem empty string is []

concat and interpolate

set first=Hello
set second=world
set /A num=20
 
rem concat
set finalstring=%first% %second%
echo %finalstring%
rem interplate
set finalstring=%first% %second% %num%
echo %finalstring%

substring

set str="this is a string"
 
echo %str:~0,4%
rem %string:~start,idx%
echo %str:~-5% rem split from right

remove string

set str="Toi yeu em"
set str=%str:Toi = %
 
rem remove space
set str=%str: =%
rem remove both end
set str=%str:~1,1%
rem replace
set str=%str:Toi=TOI%

conditional - If else

@echo off
 
set /A var=50
set /A var2=100
::          v space here
IF %var%==51 (
echo "x"
::v closing bracket must present b4 else
  ) else (
::      ^ space here
echo "y")

goto

Array

no real array in Batch

Instead some tricks are use to make it look like arrays

set StrArr[0]=Hello,
set StrArr[1]=World!
 
:: here is the trick
:: !StrArr[%%i]!
:: setlocal enabledelayexapansion
setlocal enabledelayexapansion
 
for /l %%i in (0,1,1) do (
	echo !StrArr[%%i]!
)

array length