@echo off
setlocal enabledelayedexpansion
set jd=2
rem 设置需要计算的文件夹
set "dir=c:\"
set /a KB=1024
set /a MB=1024*1024
set /a GB=1024*1024*1024
set /a TB=1024*1024*1024*1024
del /f /s /q "%cd%\calc_1.vbs"
del /f /s /q "%cd%dir_size.txt"
del /f /s /q "c:\vbs_result.txt"
rem 使用vbs脚本创建一个简单的除法计算器。
echo Dim a1,a2,a3 >>"%cd%\calc_1.vbs"
echo Dim a(2) >>"%cd%\calc_1.vbs"
echo Dim i >>"%cd%\calc_1.vbs"
echo i=0 >>"%cd%\calc_1.vbs"
echo Set oArgs = WScript.Arguments >>"%cd%\calc_1.vbs"
echo For Each s In oArgs >>"%cd%\calc_1.vbs"
echo a(i)=s >>"%cd%\calc_1.vbs"
echo i=i+1 >>"%cd%\calc_1.vbs"
echo 'MsgBox(s) >>"%cd%\calc_1.vbs"
echo Next >>"%cd%\calc_1.vbs"
echo Set oArgs = Nothing >>"%cd%\calc_1.vbs"
echo 'MsgBox(a(0)) >>"%cd%\calc_1.vbs"
echo 'MsgBox(a(1)) >>"%cd%\calc_1.vbs"
echo ' >>"%cd%\calc_1.vbs"
echo a1=145555555555555555 >>"%cd%\calc_1.vbs"
echo a2=1255555555.23 >>"%cd%\calc_1.vbs"
echo a3=a(0)/a(1) >>"%cd%\calc_1.vbs"
echo a3=round(a3,2) >>"%cd%\calc_1.vbs"
echo ' >>"%cd%\calc_1.vbs"
echo set fso=createobject("scripting.filesystemobject") >>"%cd%\calc_1.vbs"
echo set fw=fso.createtextfile("c:\vbs_result.txt") >>"%cd%\calc_1.vbs"
echo fw.write a3 >>"%cd%\calc_1.vbs"
echo fw.write "GB" >>"%cd%\calc_1.vbs"
echo 'MsgBox(a3) >>"%cd%\calc_1.vbs"
dir /a:d /b /s "%dir%" | sort /r> "%cd%\directory.txt"
for /f "usebackq delims=" %%i in ("directory.txt") do (
echo dir_is %%i;
for /f "usebackq tokens=3 delims= " %%j in (`dir /s /a /-c "%%i" ^|findstr 个文件`) do (
set z=%%j
)
echo 总大小:!z!字节
REM 下面的代码进行将文件夹的总字节数转换成MB 、GB单位。
if !z! GEQ %GB% (
rem echo 该文件夹内容小于1GB
rem echo z=!z!;
call "%cd%\calc_1.vbs" !z! %GB%
type d:\abc\vbs_result.txt
echo %%i >>%cd%\dir_size.txt
type d:\abc\vbs_result.txt |findstr .* >>%cd%\dir_size.txt
)
if !z! GEQ %MB% (
if !z! LSS %GB% (
rem echo 该文件夹内容大于1MB
set /a size1MB=!z!/%MB%
echo !size1MB! MB.
if !size1MB! GTR 10 (echo %%i >>%cd%\dir_size.txt & echo !size1MB! MB.>>%cd%\dir_size.txt)
)
)
echo ------------------------------------------------------------------------------------------------------
)
pause
递归计算指定文件夹以及子文件夹大小 - 只记录大于10M的文件夹
最新推荐文章于 2023-08-03 22:46:41 发布