FSUTIL in GB space left

时光总嘲笑我的痴心妄想 提交于 2019-12-02 11:35:16
@echo off
setlocal EnableDelayedExpansion

for /F "tokens=1* delims=:" %%a in ('fsutil volume diskfree C:') do for %%c in (%%b) do (
   set "D=%%c"
   set /A "D1=!D:~0,-8!,D2=1!D:~-8,-4!-10000,D3=1!D:~-4!-10000"
   for /L %%f in (1,1,3) do ( rem Number of divisions: KB, MB, GB
      set /A "F=0,C=0"
      for /L %%i in (1,1,3) do ( rem Quads in the number of bytes: 3*4 = 12 digits
         set /A "F+=^!^!D%%i"
         if !F! neq 0 set /A "D=C*10000+D%%i,D%%i=D/1024,C=D%%1024"
      )
   )
   set /A "C=C*10000/1024+10000
   echo %%a: !D3!.!C:~1,2! GB
)

Output example:

C:\Users\Antonio\Documents\Test> fsutil volume diskfree C:
Número total de bytes libres            : 406596222976
Número total de bytes                   : 474821423104
Número total de bytes libres disponibles: 406596222976

C:\Users\Antonio\Documents\Test> test.bat
Número total de bytes libres            : 378.67 GB
Número total de bytes                   : 442.21 GB
Número total de bytes libres disponibles: 378.67 GB
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!