How to list all folder with size via batch file

后端 未结 6 1334
故里飘歌
故里飘歌 2020-11-30 10:08

I want a simple solution for list of folders and size of them in either txt or csv format.

I use this code for folder list

dir C:\\Temp\\*.* /b /a:d          


        
6条回答
  •  伪装坚强ぢ
    2020-11-30 11:00

    My JREN.BAT utility can be used to get a list of folders with sizes. It is a hybrid JScript/batch script that runs natively on any Windows machine from XP onward.

    JREN does not conveniently convert to MB (or any other unit) - it simply lists the size in bytes. But it sure is convenient (and comparatively fast) to get the listing:

    jren "$" "' # '+size()" /d /j /list /p "d:\temp" >"C:\folderList.txt"
    

    You might consider putting the folder size first, space padded to a fixed width that exceeds the biggest folder, followed by the folder name. I find this format much easier to read, and it is still easy to parse:

    jren "^" "size('               ')+'  '" /d /j /list /p "d:\temp" >"C:\folderList.txt"
    

    The output would look something like this

               1852  SomeFolderName
            1616869  Another folder name
             137764  yetAnother
    

    Since JREN is a batch file, you must use CALL JREN if you put the command within another batch script.

提交回复
热议问题