I need to find the length of a string (variable actually) in a batch file, does anyone know how to do this simply?
This will do it: :: Send the length of the variable %MyVar%
:: to the variable %length%
set #=%MyVar%
set length=0
:loop
if defined # (set #=%#:~1%&set /A length += 1&goto loop)
echo MyVar is %length% characters long!-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br____________________________________________________________
I'm getting a syntax error when I try to use this code. Any thoughts as to why this might be happening? One thing I notice is that the command interpreter removes the %#:~1% bit. Is this by design? Thank you!
| « file sharing dos to dos n... | if expression will not ev... » |