64

I want to use the Windows command line to calculate the size of all the files in a folder and subfolder. I would normally do this by right-clicking on the folder and clicking "Properties" but I want to be able to do it on the command line.

Which command can I use?

Gareth
  • 18,809
user1605665
  • 1,089

10 Answers10

55

You will want to use dir /a/s so that it includes every file, including system and hidden files. This will give you the total size you desire.

  • 3
    Show me how the output of your command gives me the total size of the directory. Edit your answer to include it. I'll delete my comments and reverse my down vote. – dgo Dec 01 '16 at 11:13
  • 3
    @user1167442 You clearly haven't tried it. The output includes the exact same size that explorer properties gives you. – DavidPostill Dec 07 '16 at 17:08
  • 4
    @DavidPostill - you are correct. I am hang-doggedly ashamed. I will reverse the downvote. That said, I'm still not too keen on this solution - I'd prefer something a bit faster that doesn't require outputting all the other stuff, but it does work. I have erred. - Ahh nuts - it won;t let me reverse my downvote. As soon as I get the reputation to do so, I will reverse it. – dgo Dec 08 '16 at 03:23
  • @user1167442 Apology accepted. If you press the up arrow for the answer, it reverses the downvote. ;) – End Anti-Semitic Hate Dec 08 '16 at 05:17
  • it won't reverse it for me. I think it must be too soon or require more reputation before it will let me reverse it.
  • – dgo Dec 08 '16 at 12:17
  • 1
    It worked - downvote removed -) – dgo Dec 09 '16 at 00:04
  • @user1167442 Thanks. I had a hunch that would allow it to work. :) – End Anti-Semitic Hate Dec 09 '16 at 00:33
  • thanks for this +. Is there a way to list in descending size order? –  May 14 '19 at 15:14
  • 1
    @QHarr Yes, go ahead and post a question and I'll write up an answer for you. That way, it will help everyone by being searchable for all to find. – End Anti-Semitic Hate May 14 '19 at 16:23
  • 1
    /a causes the dir command to show all files and folders. See https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir – cachius Sep 20 '23 at 14:12
  • 1
    For me, this answer doesn't really answer the question - I have a large directory and want to know the TOTAL size - this command prints the size of each file - the total may be there too but it is not findable in the long list. – nrp1000 Mar 15 '24 at 13:13