This probably an easy question but I cannot find the answer. I recently found several loacations,where the batch file uses an unusual (to me) variable form.
The most recent is supposed to remove leadingbzeros from a variable. Can anyone explain what the following means?
Set n=%n:0=% <---- what is this and what does it do and how?
I know the common form of !n:~0,6! And similar but can find no explanation of n=%n:0=%
+ Reply to Thread
Results 1 to 3 of 3
By experimentation, it replaces all occurrences of the character sequence to the left of the = with the character sequence to the right of the = In this case all zeros are replaced with nothing. In the following the first "02" is replaced with "__"
Set n=000234765 echo %n% Set n=%n:02=__% echo %n% pause
Last edited by jagabo; 21st May 2018 at 21:17.
@jagabo. Thank you much. I needed to replace zeros but couldn't for the life of me figure out how it worked or find reference to it except in the example i found. Thanks again.
Update. Once you let me know it 'replaces characters i went searching again and found a reference in case anyone reads and needs this in the future. Thanks again jagabo. Master of video as well as programming! Lol
Last edited by Budman1; 21st May 2018 at 21:41.