I am trying to get the CMD equivalent of the following function bash:
$ FOO=foo.bar
$ BAR=bar
$ BAZ=baz
$ echo ${FOO/$BAR/$BAZ}
foo.baz
Now CMD has some havilny similar command substitution, when both the template and the substitution are constant:
C:\>set FOO=foo.bar
C:\>set BAR=bar
C:\>set BAZ=baz
C:\>echo %FOO:bar=baz%
foo.baz
However, I cannot reference the variables there -
C:\>echo %FOO:%BAR%=%BAZ%%
%foo:bar=baz%
How should I do it? Bonus points to indicate what also works inside the loop FORin a batch file.
source
share