0

I need your help please. I have a problem with concatenate.

SET /A "index=1"

for /f "skip=%index%" %%G IN (anoiarseeds.txt)   DO if not defined var%index% set "var%index%=%%G"

This code is working but the problem in the next step how can I echo the value of var%index% ?

%var%%index% doesn't work.

!%var%%index%%! doesn't work either.

Doug Deden
  • 2,204
  • 1
  • 12
  • 16

1 Answers1

2

You essentially have two options.

The first one requires the use of delayed variable expansion.

@echo off
setlocal enabledelayedexpansion
SET /A "index=1"
for /f "skip=%index%" %%G IN (anoiarseeds.txt) DO if not defined var%index% set "var%index%=%%G"
echo !var%index%!

The second option is getting two phases of expansion using the CALL command.

@echo off
SET /A "index=1"
for /f "skip=%index%" %%G IN (anoiarseeds.txt) DO if not defined var%index% set "var%index%=%%G"
call echo %%var%index%%%
Squashman
  • 326