First of all, you'll have to store %1 into a variable, then you will be able to perform the replacements.
Basically, the syntax for the replacement is this:
%variable:str1=str2%
which means: 'replace every str1 in variable with str2'.
In your case both str1 and str2 are parameters, not literal strings. Using the above template directly you might end up with this expression:
%variable:%3=%4%.
But that would confuse the parser, as it wouldn't know that %3 and %4 should be evaluated first. In fact, it would first try to evaluate %variable:% (and fail).
One of the solutions in this case could be to use a method called 'lazy' delayed evaluation. Basically, you are passing the command where you are evaluating a variable, to the CALL command. The transformation of the original command to its 'CALL version' is like so:
ECHO %var% ==> CALL ECHO %%var%%.
Note the double %s. At parse time they are evaluated to single %s. The resulting command would be parsed again by CALL, and the ultimate effect would be the same as in case of the original command, ECHO %var%.
So it works the same as the original command (which is good), and what we are gaining here is the later time of evaluation, I mean the final evaluation, when the variable is actually replaced with its value. Knowing about that effect, we can construct our expression in such a way that %3 and %4 are evaluated first, and then the entire resulting expression. Specifically, like this:
%%variable:%3=%4%%
After the first parse this expression would become something like this:
%variable:x=y%
That would be par
answered 2011-04-28T15:46:55.487