I need to concatenate a string after modifying an array in a windows batch script.
Can anyone point what am I doing wrong here?
For this I wrote batch script script_tests.bat
. After executing the script script_tests.bat
should be produce Tags="@TestCaseKey=2,@TestCaseKey=5"
Invoke script with parameters: script_tests.bat "testcaseIds=[2,5]"
:: script_tests.bat
:parse
IF "%~1"=="" GOTO endParse
ECHO "%~1" | FIND /I "=" && SET "%~1"
SHIFT /1
GOTO parse
:endParse
set testcaseIds=%testcaseIds:[=%
set testcaseIds=%testcaseIds:]=%
FOR %%A IN (%testcaseIds%) DO (
set Tags=@TestCaseKey=%%A,%Tags%
)
echo %Tags%