rem compute the length of a string
if defined # (
rem shorten string by one character
rem increment the string count variable %length%
set /A length += 1
rem repeat until string is null
echo myvar is %length% characters long!
Thanks to poster Secret_Doom on computing.net