2013-01-14 59 views

回答

4
@echo off 
setlocal enabledelayedexpansion 
call :COUNT "%path%" 
echo Your variable is %length% characters long 
pause >nul 

:COUNT 
set temp=%1 
set length=0 
:loop 
if defined temp (
    set temp=!temp:~1! 
    set /a length+=1 
    goto :loop 
) 

用法:call :COUNT %yourvar%和長度將被存儲在%length%

+0

有點黑客,但我會把它!感謝您快速簡潔的回答! – darkpbj

+0

哈哈,不用擔心:) –