I have the directory structure like this A->B->C,D->E,F Where A contains B folder and some text files,sql files,log files etc. B contains C folder and many other extension files. Similarly E,F are also sub-directories and contains some files. Now the output should be something like this: Count of files: A-10 A/B-15 A/B/C-20 D-25 D/E-30 F-12 Thanks for your response.All approaches are appreciated.
Have tried:
@ECHO OFF
SET "rootpath=%~1"
FOR /D %%D IN ("%~dp0*") DO (
SET cnt=0
FOR /F %%K IN ('DIR /A-D /S "%%D" 2^>NUL ^| FIND "File(s)" ^|^| ECHO 0') DO ( SET /A cnt+=%%K )
SETLOCAL EnableDelayedExpansion
ECHO %%D: !cnt!
ENDLOCAL
pause
)