If I simplified my requirement, I want to get last two digits of these strings using batch file. This is not the exact requirement. but I made it simple for understanding. :)
11-22-33
11-22-44
11-22-55
11-22-66
expected outcome is
33
44
55
66
This is the code I wrote
@echo off
SetLocal EnableDelayedExpansion
REM Fill strings to a array
set DIR_COUNT=0
for %%x in ("11-22-33" "11-22-44" "11-22-55" "11-22-66") do (
set /A DIR_COUNT+=1
set CONTENT_DIR_NAME=%%~x
set "DIR_LIST[!DIR_COUNT!]=!CONTENT_DIR_NAME!"
)
REM This part is working when I hard code the index of array to 1. I placed this two lines for testing purpose of above code.
for %%a in (%DIR_LIST[1]:-= %) do set mfgName=%%a
echo %mfgName%
REM this loop doesn't work because the syntax not correct.
for /L %%i in (1,1,%DIR_COUNT%) do (
for %%a in (%!DIR_LIST[%%i]!:-= %) do (
set mfgName=%%a
echo !mfgName!
)
)
As my understanding syntax of (%!DIR_LIST[%%i]!:-= %)
is not correct. Any ideas how to DelayedExpansion inside a DelayedExpansion and correct this syntax