0

In Windows system variable I have the following variable

x = 123 Data_123 = ddd:

How do I get this variable as a string from batch filet

So at the end I want to get the variable like "Data"_%x% and I will get the value ddd

How can I do that

Scopi
  • 663
  • 1
  • 6
  • 21

1 Answers1

1

you need delayed expansion:

@echo off
setlocal enabledelayedexpansion
set x=123
set data_123=hello
echo !data_%x%!

(there is another method without delayed expansion:

call echo %%data_%x%%%
Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91