I recently computer do not know why disk space will slowly become smaller, and after a period of time, there will be two or three GB of space is released, using I want to monitor, look at the file generated under that folder to occupy my storage space, I want to monitor the layer, and finally find out the cause.
From the Internet to find a command line to display the size of the folder directory of the batch program, but found that not very satisfactory, the total feeling is not very suitable for my use;
The first program, you can display the file size under a folder, but I want to show by layer, but not to meet my requirements, the program is as follows:
@echo ifEcho.Set/P Dirpath=please Input folderPath:Set/A s=1024*1024*1024 for/F "tokens=3 delims="%%i in ('dir/s/a/-c "%dirpath%" ^|findstr files ') Do(Setz=%%i)Echo.Echofolder:%dirpath%SetD=bitif%z% GTR 1024Set/a "z>>=10" &SetD=KBif%z% GTR 1024Set/a "z>>=10" &SetD=MBif%z% GTR 1024Set/a "z>>=10" &SetD=GBEchoThe total size is:%z%%d%&Echo.if%z% LSS%s%Echothe folder content is less than 1GPause>nul
The second program, you can display the current folder under the level directory, but not the size of each folder under the cycle, the program is as follows:
@echo off setlocal enabledelayedexpansion ( for Do ( set/a n=z=0 "%%a" for do ( set/an+=1,z+= %%~zb) set/a "z>>=20" popd Echo; %%a [!n!!z! M]) > Statistical results. txt Pause
Through the above two programs, I integrated, I intend to synthesize a program, it should be the same as the program I need to do, say dry, look at my program:
@echo offsetlocalenabledelayedexpansionEcho.Set/P Dirpath=please Input folderPath:Echo%dirpath%Echo. for/d%%a in (%dirpath%\*) Do(Set/A zz=0 for/F "tokens=3 delims="%%t in ('dir/s/a/-c "%%a" ^|findstr files ') Do(Setzz=%%t)SetD=bitif!zz! GEQ 1024Set/a "z1=!zz!>>10" &SetD=KBif!z1! GEQ 1024Set/a "z2=!z1!>>10" &SetD=KBif!z2! GEQ 1024Set/a "z3=!z2!>>10" &SetD=KBEchoFolder:%%a, size is:!z3! GB =!z2! MB =!z1!! d!) for/F "tokens=1-4 delims="%%i in ('dir/a/-c%dirpath% ^|findstr files ') Do(Set/A ss=%%kSet/A ss>>=10,d=bitif!ss! GEQ 1024Set/a "s1=!ss!>>10" &SetD=KBif!s1! GEQ 1024Set/a "s2=!s1!>>10" &SetD=KBif!s2! GEQ 1024Set/a "s3=!s2!>>10" &SetD=KBEchoIn the "%dirpath%" root directory there is%%i%%j, the total size is:!s3! GB =!s2! MB =!s1!! D! )Pause
The program also does not explain much, we can see at a glance, just put other people's things together, call method:
One: Double click to execute, follow the prompts to enter the folder path you need to build.
Two: Start-run--cmd, and then find where the bat file is stored, directly enter the bat filename to execute.
Three: can also be directly output to the file, for example: C:\>f3.bat>111.txt after the return can only see the cursor flash flash, then you directly enter the folder path can be.
Note: If the output to a file, and finally the last pause line of code (pause code) deleted, so that when the program will automatically exit after execution, will not remain in the program.
The above two programs are derived from the "Batch House", the address below for easy tracking and inspection
Reference Address: http://www.bathome.net/thread-37971-1-12.html
Find the number and total size of all files in the batch statistics folder