|
哪里改错了?
- @echo off&color 1f&echo.
- setlocal ENABLEDELAYEDEXPANSION
- for /f "delims=g" %%a in ('cmd /u /c Echo,有') do set "Tab=%%a"
- set w=wmic logicaldisk where "DriveType='3'"
- set /a max=1
- for /f "tokens=1-5" %%a in ('%w% get FileSystem^,freespace^,name^,size^,VolumeName^|find ":"')do (
- set /p=分区%%c%Tab%<nul
- call :GetSize %%b000 free
- call :GetSize %%d000 size
- set /a used=size-free
- if !size! gtr 102400 (
- set "G=GB" & set /a size/=1024,used/=1024
- ) else set "G=MB"
- set /a used=1000*used/size
- if "!used:~,-1!" == "" set "used=0!used!"
- set /p=大小: !size:~,-2!.!size:~-2!!G!%Tab%<nul
- set free1=!free!
- if !free! gtr 102400 (set /a free/=1024 & set "G=GB") else set "G=MB"
- set /p=剩余: !free:~,-2!.!free:~-2!!G!%Tab%<nul
- set /p=使用率: !used:~,-1!.!used:~-1!%%%Tab%<nul
- set /p=卷标: %%e%Tab%<nul
- set /p=格式: %%a%Tab%<nul & echo,
- if !free1! gtr !max! set max=!free1!&&set mb=!free:~,-2!.!free:~-2!!G!&&set bc=%%c
- )
- echo.&echo 分区剩余最大: 分区%bc% 剩余: %mb%
- echo.&echo 按任意键退出...&pause >nul&exit
- :GetSize
- set "num=%1" & set "n=" & set "%2="
- for %%a in (16 8 4 2 1) do (
- if not "!num:~%%a!"=="" set /a n+=%%a & set "num=!num:~%%a!"
- )
- set "num=%1" & set /a n-=6
- for /l %%a in (!n! -1 1) do (
- set "s=!num:~,-%%a!"
- if "!s:~,1!" == "0" set "s=!s:~1!"
- set /a m=s%%1048576,s/=1048576
- set "%2=!%2!!s!"
- set "num=!m!!num:~-%%a!"
- )
- if not defined %2 (
- set "%2=!num:~,-1!"
- ) else if "!%2:~,1!" == "0" set "%2=!%2:~1!"
- goto :EOF
复制代码 |
|