Основываясь на ссылке, предоставленной @minitech, вот скрипт, который должен работать:
@echo off
set /p someVar=""
::some code to figure out how long it is
::Start by writing the file to a temp file
echo %someVar%>"%temp%\tmp.txt"
:: get the files size in bytes and subtract 3 for the trailing space and newline and delete the temp file
for %%a in (%temp%\tmp.txt) do set /a length=%%~za & set /a length -=3 & del "%temp%\tmp.txt"
cls
echo someVar is %length% characters long.
pause
exit