# Solved: Batch file to give me directory disk sizes



## vince43 (Sep 20, 2008)

I'm trying to create a batch file that will give me the size of a list of directories. I'm not interested in the sizes of folders within the list of directories just the top level directory sizes, if that makes sense.
For example, I want to be able to work out the size of the user profiles on a machine, so if there were 5 users, I want to work out the size of those 5 top level profile directories.


----------



## ghostdog74 (Dec 7, 2005)

you can use diruse


----------



## TheOutcaste (Aug 8, 2007)

So what you need is the last line of the Dir /s output, the Total Files Listed: info.
The following uses a subroutine, so you can call it repeatedly from within a batch file:

```
@Echo Off
Call :_TotalSize "C:\Documents and Settings\TheOutcaste\"
Call :_TotalSize "C:\Documents and Settings\User2\"
Call :_TotalSize "%appdata%"
Goto :EOF
:_TotalSize
Set _size=0
For /F "tokens=3 delims= " %%I In ('Dir "%~1" /a-d /S ^|Find /I "file(s)"') Do Set _size=%%I
Echo The %1 tree is %_size% Bytes total
Goto :EOF
```
For a quick standalone, use just:

```
@Echo Off
Set _size=0
For /F "tokens=3 delims= " %%I In ('Dir "%~1" /a-d /S ^|Find /I "file(s)"') Do Set _size=%%I
Echo The %1 tree is %_size% Bytes total
```
use *filename "pathtocheck"* -- *pathtocheck* must be in quotes, even if you are using a variable like %userprofile% or %appdata%

Does the same as DIRUSE, but you don't have to download it

HTH

Jerry


----------



## vince43 (Sep 20, 2008)

Great, thanks both of you.
Cheers


----------



## TheOutcaste (Aug 8, 2007)

You're Welcome!

If your issue has been resolved you (and ONLY you) can mark this thread Solved by using the Mark Solved button at the Top Right of this thread (above the first post) 










Jerry


----------

