How To Replace “/” With “” in .bat File

Here is an example to replace string with a different delimiter in Windows’ *.bat file.

for /f "tokens=1-15 delims=/" %%i in ("%1") do (
set _X1_=%%i
set _X2_=%%j
set _X3_=%%k
set _X4_=%%l
set _X5_=%%m
set _X6_=%%n
set _X7_=%%o
set _X8_=%%p
set _X9_=%%q
set _XA_=%%r
set _XB_=%%s
set _XC_=%%t
set _XD_=%%u
set _XE_=%%v
set _XF_=%%w)
set _XPATH_=%_X1_%if not "%_X2_%" == "" set _XPATH_=%_XPATH_%\%_X2_%if not "%_X3_%" == "" set _XPATH_=%_XPATH_%\%_X3_%if not "%_X4_%" == "" set _XPATH_=%_XPATH_%\%_X4_%if not "%_X5_%" == "" set _XPATH_=%_XPATH_%\%_X5_%if not "%_X6_%" == "" set _XPATH_=%_XPATH_%\%_X6_%if not "%_X7_%" == "" set _XPATH_=%_XPATH_%\%_X7_%if not "%_X8_%" == "" set _XPATH_=%_XPATH_%\%_X8_%if not "%_X9_%" == "" set _XPATH_=%_XPATH_%\%_X9_%if not "%_XA_%" == "" set _XPATH_=%_XPATH_%\%_XA_%if not "%_XB_%" == "" set _XPATH_=%_XPATH_%\%_XB_%if not "%_XC_%" == "" set _XPATH_=%_XPATH_%\%_XC_%if not "%_XD_%" == "" set _XPATH_=%_XPATH_%\%_XD_%if not "%_XE_%" == "" set _XPATH_=%_XPATH_%\%_XE_%if not "%_XF_%" == "" set _XPATH_=%_XPATH_%\%_XF_%