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
  • 5
  • 20

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
  • 50,835
  • 10
  • 55
  • 88