Solved string length in ms command

November 22, 2012 at 09:49:02
Specs: XP
Have a variable in batch file, how to determine if it contains any characters or how many chrs it contains?

See More: string length in ms command

Report •

November 22, 2012 at 20:12:59
✔ Best Answer
::====== begin batchscript
@echo off & setlocal enabledelayedexpansion
set aa=0
if %1 equ "" goto :ee
set xx=%~1
set yy=!xx:~%aa%,1!
set /a aa+=1
if "%yy%" neq "" goto :xx
set /a aa-=1
echo %aa%
::===== end batchscript
or, using vbscript helper:
::==== begin batchscript #2
> len.vbs echo wscript.echo len(wscript.arguments(0))
for /f %%a in ('cscript len.vbs "%~1"') do set len=%%a
::===== end batchscript #2

Report •
Related Solutions

Ask Question