Reputation: 3256
I have a folder named Test under C:\Users\Desktop\Test I want to find count of all sub folders under folders named Zone inside Test. For example if we have folders like:
Test->Zone->Folder1 / Folder2
Test->Testing->Zone->Folder3 / Folder5
So in above scenario we will have count as 4.
I tried this script but is not working right?
@echo off
pushd C:\Users\Desktop\Test
setlocal EnableDelayedExpansion
set /a count=0
for /d %%d in ('DIR /a:d /b Zone*') do (
set /a count+=1
@echo !count!. %%d
)
pause
Upvotes: 1
Views: 1506
Reputation: 37569
Try this:
@echo off &setlocal
pushd "C:\Users\Desktop\Test"
set /a count=0
for /d /r %%i in (zone\*.*) do set /a count+=1
popd
echo %count% folder(s^)
endlocal
Upvotes: 2