Levent said:
I want to count the number of files (including hidden
ones) on each drive of my server. Does anyone have a
script about this ? Regards.
<SCREENGRAB>
D:\data\bat\help>GetDirStats d:\
Files: 163360
Dirs: 9363
Bytes: 84430239965
</SCREENGRAB>
<GETDIRSTATS.CMD>
@echo off & setlocal ENABLEEXTENSIONS
call :GetDirStats %1 files dirs bytes || (echo/Path not found. & goto :EOF)
echo/Files: %files%
echo/Dirs: %dirs%
echo/Bytes: %bytes%
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDirStats %dir% files dirs bytes
::
:: By: Ritchie Lawrence, 2003-08-11. Version 1.0
::
:: Func: Returns total number of files, directories and bytes (includes
:: sub-directories and hidden/system files/dirs). For NT4/2K/XP/2003
::
:: Args: %1 Directory to get stats (by val)
:: %2 var to receive total number of files (by ref)
:: %3 var to receive total number of directories (by ref)
:: %4 var to receive total number of bytes (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "var="
pushd %1 2>nul || (md;2>nul & endlocal & goto :EOF)
for /f "tokens=1-5* delims=," %%a in ('compact/s /q^|findstr ^^^^[0-O]') ^
do (call set "var=%%var%% %%a%%b%%c%%d%%e")
for /f "tokens=2,5,15" %%a in ('echo/%var%') do (
popd & endlocal & set "%2=%%a" & set "%3=%%b" & set "%4=%%c" & goto :EOF)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
</GETDIRSTATS.CMD>