I have the following code script:
set "file=%cd%/Config.mak"
set /a i=0
set /a j=0
@REM Delete the file if it currently exists in the folder:
IF EXIST Disabled_Features.txt del /F Disabled_Features.txt
@REM If the file can't be deleted, exit with an error:
IF EXIST Disabled_Features.txt exit 1
setlocal EnableDelayedExpansion EnableExtensions
@REM Parse Features from Config.xml into string array.
for /f "usebackq delims=" %%a in ("%file%") do (
call set /a i+=1
call set Feature[%i%]=%%a
)
@REM Regexr parametre
call set "search=:=$"
@REM Keep the Disabled Features into new array for stripping module:
for /L %%N in (1,1,%i%) do (
echo(!Feature[%%N]!|findstr /R /C:"%search%">nul && (
call echo FOUND
call set /A j+=1
call set Feature_Disabled[%j%]=!Feature[%%N]:~0,-2!
call echo.!Feature_Disabled[%j%]!>>Disabled_Features.txt
) || (
call echo NOT FOUND
)
)
endlocal
I was able to print and acces the first "for"
instruction array values, so it means they are correctly gathered from the file, but when it comes to the second "for"
instruction, the instruction !Feature[%%N]!
doesn't seem to pass a correct value to the findstr
, since the regular expression is ':=$'
, which matches the characters ':='
at the end of the line, and the array values are of the form:
EXAMPLE_SAMPLE1:=x5
EXAMPLE_SAMPLE2:=
EXAMPLE_SAMPLE3:=asdadasd
So in this case the findstr
should match the second value of the string array.
Whenever I try the command (to debug):
call echo.!Feature[%%N]!
the output shows:
!Feature[1]!
Any pointing to a proper solution for this?
Thank you a lot.