How to get the only the total files size from folders in windows commandline

How to get the only the total files size from folders dir in windows commandline [self answered]


Solution 1:

I have found elsewhere that

dir /a/s 

lists all files and folders

But to tidy this up we can use findstr, the tail of the dir command is like

Total files listed:
    nn File(s) n,nnn,nnn  bytes
    mm Dir(s)  p,pppp,ppp  bytes free

So

dir /a/s | findstr "Dir(s)"

shows the last line, which is the free bytes on the disk

Another search example

dir /a/s | findstr "Dir.File(s)"

findstr looks for each string separated by a space

So it also shows the file space used in each sub folder