Advanced Batch Files

June 1, 2009 at 17:50:25
Specs: Windows XP
I'm trying to get a batch file to remove
%SUBSET% from %VARIABLE%, and let me
use the remainder as %RESULT%. However,
I can't seem to get the SET command to parse
a nested string;


...for instance, sets %RESULT% equal to
SUBSET...not the value of the variable
%SUBSET%, but the string SUBSET.

Replacing the % symbols with ! symbols gives
the same result.

I've been able to work around this by using
ECHO to build a second, temporary batch file
where %SUBSET% is rendered as a literal
string, and reading the output of that batch file
into a temporary text file and back into the
calling batch file, but that's pretty roundabout.

Anybody know how to do a simple string
replace with two variables? I'm on XP.

See More: Advanced Batch Files

Report •

June 1, 2009 at 22:08:18
add a call in front of the statement


Report •

June 2, 2009 at 02:21:34
setlocal EnableDelayedExpansion

When using variable of variable the ! must mark the outer one.

Report •

June 2, 2009 at 12:24:37
Thanks, guys!

I tested both solutions, and they both do exactly what I
needed. You guys just made my script %20 faster - great


Report •

Related Solutions

Ask Question