I know from
call /?, the
~ in variable (e.g.
%~d1) is used to parse a part of file-path (driver here), but the tilde is used in another context here: https://www.tutorialspoint.com/batch_script/batch_script_string_length.htm:
@echo off set str = Hello World call :strLen str strlen echo String is %strlen% characters long exit /b :strLen setlocal enabledelayedexpansion :strLen_Loop if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop (endlocal & set %2=%len%) goto :eof
Here, what is the meaning of this variable expansion:
"!%1:~%len%!"? And how does it calculate the length of string via comparing it to empty string? What is the purpose of tilde here? Moreover, this example will get me into infinite loop where the output is
if not "!str:~136!" == "" set /A len+=1 & goto :strLen_Loop (where the number