void

查看磁盘剩余空间

@echo off

setlocal enabledelayedexpansion

:Main
cls
set /a num2=1024*1024
for %%i in (C D E F) do (
      set num1=0
      set num3_str=
      set num4=
      for /f "tokens=3" %%j in ('dir /-c %%i:\ 2^>nul') do set num1=%%j
      if not "!num1!"=="0" (
          call :loop
          for /f "delims=0 tokens=*" %%k in ("!num3_str!") do set num3_str=%%k
          call :lp2
          echo.
          echo.
          ::echo          %%i 盘剩余空间为 !num3_str! MB
          echo          %%i 盘剩余空间为 !var! GB
      )
          echo.
)
pause
:: goto Main

:loop
:: 求商
set /a num3=%num4%%num1:~0,1%/%num2%
:: 求商序列
set num3_str=%num3_str%%num3%
:: 求余
set /a num4=%num4%%num1:~0,1%%%%num2%
if %num4% equ 0 set num4=
set num1=%num1:~1%
if not "%num1%"=="" goto loop
goto :eof


:lp2
set nchu=%num3_str%
set nbei=1024
set var=
for /l %%a in (1 1 3) do (
       set/a m=nchu/%nbei%,mod=nchu%%%nbei%
       if %%a equ 1 (call set "var=%%var%%%%m%%.") else (call set "var=%%var%%%%m%%")
       call set "nchu=%%mod%%0"
)
::echo %var%
goto :eof

posted on 2009-02-08 16:53 void 阅读(278) 评论(0)  编辑  收藏 所属分类: 批处理


只有注册用户登录后才能发表评论。


网站导航: