Computing.Net > Forums > Programming > Batch variable name in a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch variable name in a variable

Reply to Message Icon

Name: brolon
Date: March 9, 2009 at 00:41:10 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Dear all,

I am having a trouble. I try to use the content of a variable as the name of a variable, in a loop.

When I do the following outside a loop, it works :

SET VAR_1=DONNEE
SET ITR=VAR
SET ACC=%ITR%_1
echo %ACC%   >> access.log
echo !%ACC%! >> access.log

The last line actually prints out the content of VAR_1.

But when I try to put it into a loop it fails since I can not use the '%' character.

FOR /D %%g IN (*) DO (

	SET BROL=%%g
	SET TMP_SCH=!BROL!_SCH
	SET TMP_USR=!BROL!_USR
	SET TMP_PWD=!BROL!_PWD
	
	echo !!TMP_PWD!! >> access.log
	  
)

The last line prints out the name the variable and not its content.

Does anyone have an idea to help me solve this problem ?

Best regards



Sponsored Link
Ads by Google

Response Number 1
Name: brolon
Date: March 9, 2009 at 01:25:30 Pacific
Reply:

I found out : )

FOR /D %%g IN (*) DO (

	SET TMP_PWD=!%%g_PWD!
	echo !TMP_PWD! >> access.log
	  
)


0
Reply to Message Icon

Related Posts

See More


Window Problem Script for running backup...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch variable name in a variable

Batch File: Integers in a Txt File Variable www.computing.net/answers/programming/batch-file-integers-in-a-txt-file-variable/19900.html

Batch File - Start in a new window www.computing.net/answers/programming/batch-file-start-in-a-new-window/13899.html

Editing file names in a batchscript www.computing.net/answers/programming/editing-file-names-in-a-batchscript/16864.html