Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Windows >> Command Line >> How to calculate length of a string in batch file

STRLEN.BAT

SET X=1234
SET Y=-1234
CALL :strLen X strLenX
CALL :strLen Y strLenY
ECHO.%X% is %strLenX% characters long
ECHO.%Y% is %strLenY% characters long
GOTO :eof

:strLen
setlocal enabledelayedexpansion
:strLen_Loop
   if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop
(endlocal & set %2=%len%)
GOTO :eof

Sample output

[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]