Get Folder Size from Windows Command Line

前端 未结 17 2357
滥情空心
滥情空心 2020-11-28 18:52

Is it possible in Windows to get a folder\'s size from the command line without using any 3rd party tool?

I want the same result as you would get when right clicking

17条回答
  •  执念已碎
    2020-11-28 19:50

    I recommend to use https://github.com/aleksaan/diskusage utility. Very simple and helpful. And very fast.

    Just type in a command shell

    diskusage.exe -path 'd:/go; d:/Books'
    

    and get list of folders arranged by size

      1.| DIR: d:/go      | SIZE: 325.72 Mb   | DEPTH: 1 
      2.| DIR: d:/Books   | SIZE:  14.01 Mb   | DEPTH: 1 
    

    This example was executed at 272ms on HDD.

    You can increase depth of subfolders to analyze, for example:

    diskusage.exe -path 'd:/go; d:/Books' -depth 2
    

    and get sizes not only for selected folders but also for its subfolders

      1.| DIR: d:/go            | SIZE: 325.72 Mb   | DEPTH: 1 
      2.| DIR: d:/go/pkg        | SIZE: 212.88 Mb   | DEPTH: 2 
      3.| DIR: d:/go/src        | SIZE:  62.57 Mb   | DEPTH: 2 
      4.| DIR: d:/go/bin        | SIZE:  30.44 Mb   | DEPTH: 2 
      5.| DIR: d:/Books/Chess   | SIZE:  14.01 Mb   | DEPTH: 2 
      6.| DIR: d:/Books         | SIZE:  14.01 Mb   | DEPTH: 1 
      7.| DIR: d:/go/api        | SIZE:   6.41 Mb   | DEPTH: 2 
      8.| DIR: d:/go/test       | SIZE:   5.11 Mb   | DEPTH: 2 
      9.| DIR: d:/go/doc        | SIZE:   4.00 Mb   | DEPTH: 2 
     10.| DIR: d:/go/misc       | SIZE:   3.82 Mb   | DEPTH: 2 
     11.| DIR: d:/go/lib        | SIZE: 358.25 Kb   | DEPTH: 2 
    

    * 3.5Tb on the server has been scanned for 3m12s

提交回复
热议问题