Reputation: 31
As we all know, single colon ":" can be used as a label and referred by "GOTO" statement, but in the following code I don't know what does ":" mean here, can you help me :)
set "str=!str:Mode_1=%_MODE%!" 2>nul
Thank you!
Upvotes: 0
Views: 4142
Reputation: 340516
From the set /?
help message:
Environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded output. "str1" can begin with an asterisk, in which case it will match everything from the beginning of the expanded output to the first occurrence of the remaining portion of str1.
So !str:Mode_1=%_MODE%!
will replace any instance of "Mode_1" in str
with the value of the variable %_MODE%
. (the exclamation marks are being used for delayed expansion of str
)
Upvotes: 3
Reputation: 52008
The colon in the set
command is used for string substitution. See this. The line that you gave still seems quite cryptic and doesn't quite match the examples of string substitution that I was able to find online.
Upvotes: 1