Count files within folders in a directory

January 31, 2011 at 13:00:16
Specs: Windows XP
Hello,

I'm trying to write a batch file to count the number of files within folders of a given directory and then print them to a text document. I have code that will show on the screen exactly what I want to see but can't seem to get the proper command to send it to a file.

what I have is
@echo off
for /d %%a in (*) do (
<nul set/p =%%a
dir/b/a-d "%%a" 2>nul|find/c /v ""
)

I know the proper command is >>(filenameIwant.txt) but where do I put it? I know it's a pretty noob question but it's driving me nuts.

Thankyou in advance


See More: Count files within folders in a directory

Report •

#1
January 31, 2011 at 13:43:02
:: ==========================================
::
:: sgerena.bat Tue 01-02-2011 4:21:29.47
@echo off > %TEMP%\newfile & setLocal enableDELAYedeXpansion

pushd c:\files
for /f "tokens=* delims= " %%a in ('dir/s/b/ad') do (
set N=
pushd %%a
for /f "tokens=* delims= " %%d in ('dir/b/a-d') do (
set /a N+=1
)
>> %TEMP%\newfile echo.%%a has !N!
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
January 31, 2011 at 14:00:36
Thank you, using that I was able to get it to work.

Report •
Related Solutions


Ask Question