Reputation: 23
I keep seeing "set y=%y:~0,-2%" or some visual equivalent to it in code, but I have no idea what it's called, what it does, or how it's syntax works; I haven't been able to find an explanation, just more uses of it. Can some one explain?
Upvotes: 1
Views: 13993
Reputation: 22
Set is used to set variables eg.: set /p A=
will ask the user for input.
in cmd type set /?
Upvotes: 0
Reputation: 121599
"Set" sets the value of a Windows variable.
EX: set myvar=abc
<= assigns the string "abc" to variable "%myvar"
"%" deferences the current value of a Windows Variable.
EX: echo %myvar%
<= prints "abc"
The %y:~0,-2
syntax extracts a substring from the current value of the variable
<= extracts last 2 characters from Windows variable "%y"
Here are some useful links that might help :
Upvotes: 1