Tom's Guide | Tom's Hardware | Tom's Games | PC Safety Suite
![]() |
![]() |
![]() |
Comment:
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;SET RESULT=%VARIABLE:%SUBSET%=%
...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.
+1 | ![]() |
setlocal EnableDelayedExpansion set RESULT=!VARIABLE:%SUBSET%=!
When using variable of variable the ! must mark the outer one.
+1 | ![]() |
Thanks, guys!
I tested both solutions, and they both do exactly what I
needed. You guys just made my script %20 faster - great
work.~Mike
![]() |
Batch File Save Game
|
Hi, need one help!!
|

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