I assume that you are using the delayed expansion character because you are working inside a set of brackets "()". Doing that makes your process harder. I know that method is easier to read, but it is harder to code for.
Inside brackets, I know of only one method to access a variable that was 'built' out of one or more variables. That is to use the call
function to cause the assembled variable to 'activate'. This method works both inside and outside of brackets.
Here is a small example:
@echo off
setlocal enabledelayedexpansion
(
set i=10
set _c!i!=something
:: below is equivalent to echo !_c10!
call echo %%_c!i!%%
)
endlocal
Output:
something
You can do almost everything using a CALL
in front of it that you can without it, though in XP or earlier you cannot call internal commands like if
and can only call 'external' programs like FIND.EXE.
If you can work outside of a set of brackets by possibly using a call :label
statement, you can simply access the variable like this:
@echo off
setlocal enabledelayedexpansion
set i=10
set _c!i!=something
:: The below 2 statements are equivalent to `echo %_c10%`
echo !_c%i%!
call echo %%_c!i!%%
endlocal
Output:
something
something