Delayed expansion acts weird in my for loop. At the first iteration study is defined, at the second iteration it seems the delayed expansion doesn't work (delayed expansion is used just to strip the colon out because that will be the name of a directory). It is like that cypress command breaks something. Is that somehow related to how that cypress CLI works or there is something wrong with my script?
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:parse
IF "%~1"=="" GOTO endparse
IF "%~1"=="-s" SET studies=%~2
SHIFT
GOTO parse
:endparse
for %%a in ("%studies:,=" "%") do (
set tmp=%%~na
set study=!tmp::=!
echo study %%~a delayedExString: !study!
npx cypress run -study=%%~a --config videosFolder=cypress/videos/!study! --headless --spec "cypress/integration/*"
)
Example:
myscript.bat -s "firstStudy:Chap1,secondStudy:Chap3"
Console output:
study firstStudy:Chap1 delayedExString firstStudyChap1
[...cypress log...]
study secondStudy:Chap3 delayedExString !study!
[...cypress log...]
As you can see, in the second iteration study is not expanded.