Directory Size
10:38 PM@echo
off
:: ===================================================================================================
::
:: Name: dirsize.cmd
:: Description: Script written to poll directory size attributes into flat files
for
each server
:: specified in the accompanying dirs.txt and servers.txt file
:: Written By: Aslam latheef
:: Date:
8
/
4
/
2010
::
:: Script Usage: dirsize.cmd
:: Result Code: N/A
:: Example: D:\Windows\Scripts\dirsize.cmd
::
::
:: *** Notes ***
::
::
1
) Batch script requires the du.exe command line utility from sysinternals.com
::
2
) The file servers.txt should be in the same directory with the contents having on each line a
:: single server that can be resolved by the client.
::
3
) The file dirs.txt are the directories identified one per line that are needed
for
stats.
::
4
) All content gets written to by
default
the D:\WINDOWS\Scripts directory
::
5
) The script assumes the system has remote CIFS access to the directories specified in the
:: dirs.txt file.
::
6
) For more information or help, please email corp-tech
@opsource
.net.
::
:: ===================================================================================================
:: Sets help variable
set HELPMSG=/?
:: Checks
for
help argument being passed
IF
"%1"
==
"%HELPMSG%"
GOTO USAGE
:: Set user defined variables
SET OPSBINDIR=D:\Program Files\opsbin
SET PARSESRVFILE=D:\WINDOWS\Scripts\servers.txt
SET PARSEDIRFILE=D:\WINDOWS\Scripts\dirs.txt
SET LOGDIR=D:\WINDOWS\Scripts
:: ===================================================================================================
::
:: *** WARNING - DO NOT MODIFY!!! ****
::
:: Please
do
not modify the code below
this
section as that can cause the script to fail or perform
:: in an unintended manner. If you decide to anyways,
do
at your own risk.
::
:: ===================================================================================================
:: For loop that requires du.exe to run successfully; Command exports data
for
each server name in the
:: LOGDIR variable above
@echo
on
for
/f %%i in (%PARSESRVFILE%)
do
(
for
/f
"tokens=1 delims=,"
%%j in (%PARSEDIRFILE%)
do
"%OPSBINDIR%\du.exe"
-q
"\\%%i\%%j"
) >> %LOGDIR%\%%i_Results.log
@echo
off
echo.
echo Please go to the directory %LOGDIR% to see the results...
echo.
pause
GOTO END
:END
exit
:USAGE
echo.
echo *** Usage ***
echo.
echo Script Usage: dirsize.cmd
echo Result Code: N/A
echo Example: D:\Windows\Scripts\dirsize.cmd
echo.
echo For more information on the script contents please read the remarks
echo at the top of
this
batch file.
0 comments