batch Dir usage listing

I have a "users" dir with all my users home dir,

I would like to have a batch file to check all dir and output the dir name and size like,
to a file

user1 296mb

user2 100mb

user3 512mb
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Rather then creating a script - which could be done, but probably take a while, I'd recommend downloading DIRUSE.EXE from

This tool does EXACTLY that with various options.  I'll try to post exactly what options you would use to get such output.
CMILLERAuthor Commented:
that will work
Lee W, MVPTechnology and Business Process AdvisorCommented:
This is the help/usage screen from the command:

DIRUSE displays a list of disk usage for a directory tree(s). Version 1.20

DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]] [/*] DIRS

/S    Specifies whether subdirectories are included in the output.
/V    Output progress reports while scanning subdirectories.  Ignored if /S is specified.
/M    Displays disk usage in megabytes.
/K    Displays disk usage in kilobytes.
/B    Displays disk usage in bytes (default).
/C    Use Compressed size instead of apparent size.
/,    Use thousand separator when displaying sizes.
/L    Output overflows to logfile .\DIRUSE.LOG.
/*    Uses the top-level directories residing in the specified DIRS
/Q:#    Mark directories that exceed the specified size (#) with a "!".
    (If /M or /K is not specified, then bytes is assumed.)
/A    Specifies that an alert is generated if specified sizes are exceeded.
    (The Alerter service must be running.)
/D    Displays only directories that exceed specified sizes.
/O    Specifies that subdirectories are not checked for specified size
DIRS    Specifies a list of the paths to check.

Note:    Parameters can be typed in any order. And the '-' symbol can be
    used in place of the '/' symbol.

    Also, if /Q is specified, then return code is ONE if any directories are found that
    exceed the specified sizes.  Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\users

The command you would use for listing of user directory sizes would be:
diruse /m /, /* d:\users

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Assuming your users home folders were D:\USERS\<username>
CMILLERAuthor Commented:
yea, they are

is there a way to output to a file?
Lee W, MVPTechnology and Business Process AdvisorCommented:
ALMOST Anything that spits out information in a DOS window can be sent to a file by appending "> filename.ext" to the end of the command.

So to put that info into a file, you can use:

diruse /m /, /* d:\users > diruse.log
CMILLERAuthor Commented:
That works, thanks

Lee W, MVPTechnology and Business Process AdvisorCommented:
One of these days, I'm going to put together a web site to refer people to, but here's a little more on file redirection:

There's two primary outputs in a DOS window - STANDARD OUT (also known as StdOut) and STANDARD ERROR (also known as StdErr).  By default, both of these OUTput to the screen.  But that can be changed using the ">" and ">>" characters at the end of a command.

For example, if you type "DIR" in a dos window and hit enter, you see a directory listing.  If you want this listing to go to a file, you can say DIR > DIR.TXT and nothing will show up on the screen, but a file called DIR.TXT will be created with what WOULD have shown on the screen.  It's important to note that the ">" character will create the filename specified after it and if the file ALREADY exists, it will OVERWRITE it, effectively erasing the old file.  You CAN append to the file by using a double sign - ">>" Here's an example:


Executing the above two commands results in a file that contains ONLY the directory listing of D - the output from DIR C:\ was destroyed when the file was overwriten by DIR D:\.


Executing the above two commands results in a file that contains BOTH the directory from c: AND the directory from D:

Sometimes you might want to ensure both standard error and standard out go to the same file.  To do this, you would simply append a 2>&1 or 2>>&1.  Why does this work?  Well:

"1>" and ">" are effectively the same.  the 1 represents standard out - and is the default when you just say ">".  Standard Error is referred to as 2.  So by saying:
DIR C:\ > DIR.TXT 2>&1 you are saying to send the ERROR information to the SAME file as the standard output.  With DIR you're not likely to see many instances that use Standard error.  But especially with copy and other commands, errors can occur.  Failure to specify you also want standard error to be sent to a file means your log is basically a SUCCESS ONLY log.  

You can also specify each goes to a different file.  For example:
All errors will be recorded in DIR.ERR while all successes (regular text output) will be recorded in DIR.TXT

Hope this was useful.

NOTE: programs that pop up a window with the help info will NOT work with standard out and standard error - but those that dump info to a DOS window will ALMOST always work with it - though sometimes you have to figure out which output it's using (the NET command is strange like this).
CMILLERAuthor Commented:
very useful thanks,

another question,

I have been trying to figure out over the last few days on how to use msbacli.exe, hfnetchk.exe, and qchain.exe
to update my pc's, I am running sus but I need to update faster that microsoft puts patches out and I have a lab
thats not on the network that needs to stay patched

I think I have all my cli down to what I want, basically what I would like is to either run a command line to get all info
and have it patch based on other files or have someone help build a gui of some sort with say VB,
either way I want it simple to update.

any suggestions?

Lee W, MVPTechnology and Business Process AdvisorCommented:
I'm sorry - I can't help much on that one.  I've used HFNETCHK - but not the other apps.  But I applaud your efforts to stay up to date on patches.  If you are concerned about security (and you seem to be), I'd check out (and subscribe to) the NTBUGTRAQ mailing list.  See
CMILLERAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.