Q:

Counting how many characters are in a string outputting syntax incorrect

I'm trying to count how many characters are in a string using the following:
set "vnum=0.1.2"
for %%i in (%vnum%) do set count=%%~szi
if %count%==5(
    set "vtype=dev"
) else if %count%==3 (
    set "vtype=stable"
) else (
    set "vtype=unknown"
)
@echo "v%vnum%(%vtype%)"
@echo.

However when I run it, it's outputting The syntax of the command is incorrect.
What am I doing wrong to where I cannot obtain the length of the string?

A:

set "vnum=0.1.2"
set "vtype=unknown"
if defined vnum (
 if "%vnum:~4%" neq "" if "%vnum:~5%" equ "" set "vtype=dev"
 if "%vnum:~2%" neq "" if "%vnum:~3%" equ "" set "vtype=stable"
)

@echo "v%vnum%(%vtype%)"
@echo.

The syntax %var:~m,n% means "the substring of var starting at index m for a length of n" where m starts at 0 for the first character. n need not be specified (when it means "for the rest of the string") m or n may be negative  where they mean "from the end of the string".
So - if the 5+ character exists, but the 6+ does not, then the length is 5, so dev; similar argument for 3. Start with fail then override if pass.
Your code failed for two reasons - first, the ~sz idea that has already been mentioned and second, thre must be a space before the ( in an if otherwise the ( is assumed to be part of the second string to be compared. Batch always compares strings - numerics are stored as strings and mathematical functions are performed by converting from strings to integers for calculations then back to strings for storage/display.

