开发者

Batch file that returns folder size

I'm having space issues on my Vista machine and need to figure out what's taking up so much space.

I would like to write a simple batch file that returns all 开发者_如何学Gofolders under C: and the size of each folder.

The dir command doesn't appear to return folder size.

Unfortunately we don't have admin rights and can't install a third party application and we have other users in our group that also need this information.


I'd have a look at this thread for some clues as to how to achieve the directory size:

Batch File To Display Directory Size

Otherwise:

dirsize:

@echo off
setLocal EnableDelayedExpansion
set /a value=0
set /a sum=0
FOR /R %1 %%I IN (*) DO (
set /a value=%%~zI/1024
set /a sum=!sum!+!value!
)
@echo %CD%:!sum! k

AllDirSize:

echo off
set WORKING_DIRECTORY=%cd%
    for /f "delims=" %%a in ('dir /a:D /D /B /S') do (  
            echo off
            cd %%a
            "%WORKING_DIRECTORY%"\dirsize "%%a"
            cd %WORKING_DIRECTORY%
) 

Use it: ALLDIRSIZE > C:\temp\FileContainingFolderSizes.txt

Which is taken from the excellent Richard Bishop testing forums: http://www.bish.co.uk/forum/index.php?topic=58.0


Not exactly answering your question, but if you have GUI access I'd suggest using TreeSize: http://www.jam-software.com/freeware/index.shtml

If you prefer command line use du command from Unix utils: http://unxutils.sourceforge.net/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜