counting chars in file name DOS batch
for example I have a foldet test and some files there : test1.txt,
test12.txt, test123.txt ... i want a batch program to count characters in
these filenames and output on the screen like - name "test1.txt" consists
of 9 chars... name "test12.txt" consists of 10 chars... and so on.
i wrote this script but it does't work :(
@echo off
setlocal enableextensions enabledelayedexpansion
set /p directory="specify Desirable Dir: "
pushd "%directory%"
for %%j in (*) do (
set /a countch=0
set OFileName=%%j
:loop
set NFileName=!OFileName:~0,%countch%!
IF !OFileName!==!NFileName! (
echo name "!OFileName!"
consists of %countch%
chars
) ELSE (
set /a countch =
countch + 1
goto loop
)
)
popd
endlocal
pause
please help! thanks in advance ;)
No comments:
Post a Comment