Solved Count number of files in the directory

May 14, 2012 at 06:24:00
Specs: Windows XP
Hi i have taken the following batch script from Computing.net

dir /a-d | find /c ".xls" > NUMfiles.###
set /p count=<NUMfiles.###
Echo %count% > count.txt

When i executed it im not getting the ouput...im trying to count the no of xls files in D:\ drive...
What exactly they have done in the batch to count the files...Thank you guys...


See More: Count number of files in the directory

Report •


#1
May 14, 2012 at 15:11:05
:: ==========================================
::
:: rajk.bat Mon 14-05-2012 23:48:54.52
@echo off & setLocal enableDELAYedeXpansioN

set N=

for /f "tokens=* delims= " %%a in ('dir/b *.xls') do (
set /a N+=1
)
> count.txt echo.!N!

::===========================================


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

M2


Report •

#2
May 15, 2012 at 06:56:40
Hi Mechanix2go , im getting the no of files only in the present folder but not in the directory :(

Report •

#3
May 15, 2012 at 07:01:50
✔ Best Answer
Perhaps:

:: ==========================================
::
:: rajk.bat Mon 14-05-2012 23:48:54.52
@echo off & setLocal enableDELAYedeXpansioN
set N=
for /f "tokens=* delims= " %%a in ('dir /s /b d:\*.xls') do (
set /a N+=1
)
echo.!N!

Tony


Report •

Related Solutions


Ask Question