This will list all the folders, but it will only list the sizes of those > 100MB:
dir/s | findstr/r " bytes | Directory " | findstr "...,...,..."
Main Topics
Browse All TopicsRunning on Windows Server 2003.
I am having disk space issues. I want to generate a report of all folders larger that a certain size, say 500 MB. I would love to have this in a simple batch file I can fire off on a schedule so I can have the results emailed to myself. How would I go about this?
Ideally, I would end up with a list of folders larger than the set amount and a listing of the name and size of their contents. There must be an easy way to do this, yes?
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
That is a great idea! Here's the rest of the code:
@echo off
setlocal
set srcDir=c:\
set outFile=%cd%\output.txt
set /a threshold=500000000
if exist "%outFile%" del "%outFile%"
pushd "%srcDir%"
for /f "tokens=1,2*" %%a in ('dir /s /-c ^| findstr /r " bytes ^| Directory "') do call :PROCESS "%%a" "%%c"
popd
if not exist "%outFile%" (echo No directories are over %threshold%)>>"%outFile%"
echo Results in %outFile%
goto :EOF
:PROCESS
if "%~1"=="Directory" set dirName=%~2&goto :EOF
call :GETBYTES %~2
if "%bytes%"=="" goto :EOF
if /i %bytes% GTR %threshold% (echo %dirName% has %~2 bytes)>>"%outFile%"
goto :EOF
:GETBYTES
set bytes=
if "%~3"=="free" goto :EOF
if "%~2"=="bytes" set bytes=%~1
goto :EOF
Try diruse.exe from the Support Tools, for example like this:
diruse /s /d /m /q:500 C:\
/l would create a logfile diruse.log in the folder you're in when you run the command.
Windows Server 2003 Service Pack 1 32-bit Support Tools
http://www.microsoft.com/d
Windows Server 2003 Service Pack 2 32-bit Support Tools
http://www.microsoft.com/d
If you wouldn't mind using a VBS version, here's one that outputs to Excel and sorts the folders by size (using Excel, so kind of cheating, but hey, it's easier!).
NOTE: You must have DirUse.exe in your %systemroot%\System32 folder.
'============
'================
strLogFileName = "Results.txt"
strResultsFile = Replace(WScript.ScriptFull
strFolderToCheck = "C:\Temp"
Set objShell = CreateObject("WScript.Shel
strCommand = "cmd /c diruse /s /m " & """" & strFolderToCheck & """" & " > """ & strResultsFile & """"
objShell.Run strCommand, 0, True
Set objFSO = CreateObject("Scripting.Fi
Const intForReading = 1
Set objResults = objFSO.OpenTextFile(strRes
While Not objResults.AtEndOfStream
strLine = objResults.ReadLine
'If InStr(strLine, "Size (mb)") = 0 Then
If strLine <> "" Then
strNewLine = Trim(Left(strLine, 13)) & "|"
strNewLine = strNewLine & Trim(Mid(strLine, 14, 7)) & "|"
strNewLine = strNewLine & Trim(Mid(strLine, 21))
If strResults = "" Then
strResults = strNewLine
Else
strResults = strResults & VbCrLf & strNewLine
End If
End If
'End If
Wend
objResults.Close
Set objResults = Nothing
objFSO.DeleteFile strResultsFile, True
'MsgBox strResults
Set objExcelApp = CreateObject("Excel.Applic
Const xlAscending = 1
Const xlDescending = 2
Const xlCalculationManual = -4135
Const xlCalculationAutomatic = -4105
objExcelApp.Visible = True
objExcelApp.Workbooks.Add
objExcelApp.Calculation = xlCalculationManual
objExcelApp.ScreenUpdating
arrResultsRows = Split(strResults, VbCrLf)
ReDim arrResultsTable(UBound(arr
For intRowNum = LBound(arrResultsRows) To UBound(arrResultsRows)
For intColNum = LBound(Split(arrResultsRow
objExcelApp.ActiveSheet.Ce
'arrResultsTable(intRowNum
Next
Next
objExcelApp.ActiveSheet.Ce
objExcelApp.Selection.Sort
objExcelApp.ActiveSheet.Ra
'objExcelApp.Calculation = xlCalculationAutomatic
objExcelApp.ScreenUpdating
MsgBox "Done"
'===============
Regards,
Rob.
And if you are still intrested in the e-mailing part. I use bmail and mpack as a command line mailer (e-mails with attachment you want).
http://www.beyondlogic.org
I use it for emailing me important logs i need to check. Works great :) If you need any help with this just ask.
Business Accounts
Answer for Membership
by: knightEknightPosted on 2007-06-26 at 14:48:01ID: 19368130
This will at least show you how big each folder is. Next step is to filter all the folder < 500MB
dir/s | findstr/r " bytes | Directory "