Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dos command for file size of a folder and all of it’s contents.

Status
Not open for further replies.

WebAppsIT

Technical User
Nov 3, 2009
3
0
0
US
Does anybody know how to use a DOS command that will list the file size of a folder and all of it’s children / contents in a single line format? I know how to use a dos command to make the listing but the file size is always included on the last row. I would like to make it only list the size of the contents.
Thank you,
Chris
 
hmmm. i dont think there is a command that does just that, but you might be able to automate it by the use of a few commands running in conjunction with one another.

im not sure if this is going to do exactly what you want so you might want to read this whole post before doing it.

download the server 2003 resource kit:


install it. it will install several command line utilities. by default it will install under program files- i find that is fairly inconvenient, so i install it to c:\tools. anyway. you might also want to put the directory you installed them to in your path, OR, just copy the newly installed file "qgrep.exe" to wherever you want to use it.

now by using a dir command, telling it to display all files (including hidden) in the current directory and all subdirectories, you can parse the output with the qgrep command. the last 'bytes' entry will be the total bytes of all files in the directory and subdirectories.


C:\Documents and Settings\Owner\Desktop\ftp>path c:\tools

C:\Documents and Settings\Owner\Desktop\ftp>dir /s /a |qgrep bytes
1 File(s) 3,068,630 bytes
2 File(s) 6,137,260 bytes
3 File(s) 9,205,890 bytes
5 Dir(s) 57,337,323,520 bytes free

in my example above, the folder 'ftp' only has 1 file and it is ~3 megs. i copied that same file twice more into a newly created subdirectory. so the first 'bytes' entry is that 1 file, the second 'bytes' entry is the two files, and the last 'bytes' entry is the combined total of all files listed. the final 'bytes free' is of course the remaining drive space on the volume.

you can read up on qgrep to see if it will do anything more complex than that... but to be honest i dont think it will trim up the output for your particular need any more than that..... you might end up having to use awk.

im not well versed in using awk... although i should learn. its exceedingly exceedingly useful. i have no doubt that it could do what you want to do, but i dont know the exact command you would need to run.

here is a link to the dos version of it and documentation:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top