michaeluskov
michaeluskov

Reputation: 1828

Get sum of all files' size in a directory in CMD

How can I get sum of sizes of all files which are located in a directory (but exclude files in subdirectories)?

Upvotes: 1

Views: 23026

Answers (3)

bonCodigo
bonCodigo

Reputation: 14361

Assuming in MS DOS: But this doesn't exclude the sub folders and hidden files ;)

Try:

dir /a/s

Result in : Files for current directory and subdirectories wih their hidden files. And total size for all of them.

enter image description here

PS: Frankly, there's a GUI you can get the folder size and number of files within. Curious to know why you want to do so within DOS? ;)

Upvotes: 1

pbhd
pbhd

Reputation: 4467

This information is included in the output of the dir-command. In the line before the last output line is the number of files and the tortal size displayed.

Upvotes: 0

jimhark
jimhark

Reputation: 5046

Using the dir command, the total bytes is displayed in the next to the last line. You could use:

dir | findstr "File(s)"

To get only this information for the current directory. Or

dir path | findstr "File(s)"

to get total size in the given path, for example:

dir c:\windows | findstr "File(s)"

Upvotes: 3

Related Questions