有谁知道如何只显示小数点后的 2 个字符。
示例:19.123948493114 变成 19.12
不能使用 %variable:~5% 因为小数点前的数字会发生变化,所以有时会是 19 其他时候会是 123451213.12345123
两者都只需要显示小数点后 2 个字符
-= 编辑 =- 这是我当前的脚本。
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
CLS
FOR /F "tokens=1*" %%A IN ('fsutil fsinfo drives') DO SET "Drives=%%B"
FOR %%A IN (%Drives%) DO fsutil fsinfo statistics %%A |FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." >nul || CALL:GetDriveInfo %%A
EXIT /B
:GetDriveInfo
SET "CurrentDrive=%~1"
SET "CurrentDrive=%CurrentDrive:\=%
FOR /F "tokens=7 delims= " %%A IN ('fsutil volume diskfree %~1 ^|FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%%A"
FOR /F "tokens=6 delims= " %%A IN ('fsutil volume diskfree %~1 ^|FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%%A"
FOR /F %%A IN ('powershell %CurrentDrive-TotalSpace% - %CurrentDrive-FreeSpace%') DO Set "CurrentDrive-UsedSpace=%%A"
FOR /F "tokens=1-2 delims=." %%A IN ('powershell %CurrentDrive-UsedSpace% / %CurrentDrive-TotalSpace% * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%%A"
SET "CurrentDrive-UsedSpace-Percent2=%%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
FOR /F "tokens=1-2 delims=." %%A IN ('powershell %CurrentDrive-FreeSpace% / %CurrentDrive-TotalSpace% * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%%A"
SET "CurrentDrive-FreeSpace-Percent2=%%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
ECHO Drive Information For %CurrentDrive%
ECHO/ Used Space: %CurrentDrive-UsedSpace% (%CurrentDrive-UsedSpace-Percent%%%)
ECHO/ Free Space: %CurrentDrive-FreeSpace% (%CurrentDrive-FreeSpace-Percent%%%)
ECHO/ Total Space: %CurrentDrive-TotalSpace%
ECHO/
EXIT /B
:GetDriveInfo-Convert
FOR /F %%A IN ('powershell %~2 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%%A"
FOR /F "Tokens=1-2 delims=." %%A IN ("%CurrentDrive_Temp%") DO SET "CurrentDrive_Temp1=%%A" & SET "CurrentDrive_Temp2=%%B"
SET "CurrentDrive_Temp3=%CurrentDrive_Temp2:~0,2%"
:: Rounds Up to get a more accurate number. Used to counter the lost bytes.
IF "%CurrentDrive_Temp2:~2,1%" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
IF "%CurrentDrive_Temp3%"=="100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
SET "%~1=%CurrentDrive_Temp1%.%CurrentDrive_Temp3%"
EXIT /B
问题?其中一个驱动器似乎无缘无故地不想切断。
我的结果:
Drive Information For C:
Used Space: 103.21 (86.5%)
Free Space: 16.04 (13.4%)
Total Space: 119.25
Drive Information For D:
Used Space: 481.37 (57.8%)
Free Space: 350.14 (42.1%)
Total Space: 831.51
Drive Information For E:
Used Space: 530.02 (99.7%)
Free Space: 1.49 (0.2%)
Total Space: 531.51
Drive Information For F:
Used Space: 86.4 (43.2%)
Free Space: 113.60 (56.8%)
Total Space: 200.00
Drive Information For G:
Used Space: 0.129999999999995 (0.0%)
Free Space: 199.87 (99.9%)
Total Space: 200.00
Drive Information For I:
Used Space: 86.83 (9.3%)
Free Space: 844.68 (90.6%)
Total Space: 931.51
Drive Information For J:
Used Space: 699.09 (75.0%)
Free Space: 232.39 (24.9%)
Total Space: 931.48
Drive Information For Z:
Used Space: 11.06 (22.1%)
Free Space: 38.94 (77.8%)
Total Space: 50.00
我的缩短脚本调试文件。我切断了 C: 驱动器的整个功能以及 G: 驱动器之后的所有内容,因为这是问题所在的驱动器,我不能发布超过 30k 个字符 xD
D:\Desktop>SETLOCAL ENABLEEXTENSIONS
D:\Desktop>SETLOCAL ENABLEDELAYEDEXPANSION
D:\Desktop>CLS
D:\Desktop>FOR /F "tokens=1*" %A IN ('fsutil fsinfo drives') DO SET "Drives=%B"
D:\Desktop>SET "Drives=C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ X:\ Y:\ Z:\ "
D:\Desktop>FOR %A IN (C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ X:\ Y:\ Z:\) DO fsutil fsinfo statistics %A | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo %A
D:\Desktop>fsutil fsinfo statistics D:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo D:\
D:\Desktop>SET "CurrentDrive=D:\"
D:\Desktop>SET "CurrentDrive=D:
D:\Desktop>FOR /F "tokens=7 delims= " %A IN ('fsutil volume diskfree D:\ |FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%A"
D:\Desktop>Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "375962980352"
D:\Desktop>FOR /F %A IN ('powershell 375962980352 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=350.142810821533"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("350.142810821533") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=350" & SET "CurrentDrive_Temp2=142810821533"
D:\Desktop>SET "CurrentDrive_Temp3=14"
D:\Desktop>IF "2" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "14" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-FreeSpace=350.14"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F "tokens=6 delims= " %A IN ('fsutil volume diskfree D:\ |FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%A"
D:\Desktop>CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "892827856896"
D:\Desktop>FOR /F %A IN ('powershell 892827856896 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=831.510738372803"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("831.510738372803") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=831" & SET "CurrentDrive_Temp2=510738372803"
D:\Desktop>SET "CurrentDrive_Temp3=51"
D:\Desktop>IF "0" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "51" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-TotalSpace=831.51"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F %A IN ('powershell 831.51 - 350.14') DO Set "CurrentDrive-UsedSpace=%A"
D:\Desktop>Set "CurrentDrive-UsedSpace=481.37"
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 481.37 / 831.51 * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%A"
SET "CurrentDrive-UsedSpace-Percent2=%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-UsedSpace-Percent1=57"
SET "CurrentDrive-UsedSpace-Percent2=8910656516458"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 350.14 / 831.51 * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%A"
SET "CurrentDrive-FreeSpace-Percent2=%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-FreeSpace-Percent1=42"
SET "CurrentDrive-FreeSpace-Percent2=1089343483542"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>ECHO Drive Information For D:
Drive Information For D:
D:\Desktop>ECHO/ Used Space: 481.37 (57.8%)
Used Space: 481.37 (57.8%)
D:\Desktop>ECHO/ Free Space: 350.14 (42.1%)
Free Space: 350.14 (42.1%)
D:\Desktop>ECHO/ Total Space: 831.51
Total Space: 831.51
D:\Desktop>ECHO/
D:\Desktop>EXIT /B
D:\Desktop>fsutil fsinfo statistics E:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo E:\
D:\Desktop>SET "CurrentDrive=E:\"
D:\Desktop>SET "CurrentDrive=E:
D:\Desktop>FOR /F "tokens=7 delims= " %A IN ('fsutil volume diskfree E:\ |FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%A"
D:\Desktop>Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "1599143936"
D:\Desktop>FOR /F %A IN ('powershell 1599143936 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=1.48931884765625"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("1.48931884765625") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=1" & SET "CurrentDrive_Temp2=48931884765625"
D:\Desktop>SET "CurrentDrive_Temp3=48"
D:\Desktop>IF "9" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "49" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-FreeSpace=1.49"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F "tokens=6 delims= " %A IN ('fsutil volume diskfree E:\ |FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%A"
D:\Desktop>CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "570704261120"
D:\Desktop>FOR /F %A IN ('powershell 570704261120 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=531.509761810303"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("531.509761810303") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=531" & SET "CurrentDrive_Temp2=509761810303"
D:\Desktop>SET "CurrentDrive_Temp3=50"
D:\Desktop>IF "9" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "51" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-TotalSpace=531.51"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F %A IN ('powershell 531.51 - 1.49') DO Set "CurrentDrive-UsedSpace=%A"
D:\Desktop>Set "CurrentDrive-UsedSpace=530.02"
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 530.02 / 531.51 * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%A"
SET "CurrentDrive-UsedSpace-Percent2=%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-UsedSpace-Percent1=99"
SET "CurrentDrive-UsedSpace-Percent2=7196666102237"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 1.49 / 531.51 * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%A"
SET "CurrentDrive-FreeSpace-Percent2=%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-FreeSpace-Percent1=0"
SET "CurrentDrive-FreeSpace-Percent2=280333389776298"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>ECHO Drive Information For E:
Drive Information For E:
D:\Desktop>ECHO/ Used Space: 530.02 (99.7%)
Used Space: 530.02 (99.7%)
D:\Desktop>ECHO/ Free Space: 1.49 (0.2%)
Free Space: 1.49 (0.2%)
D:\Desktop>ECHO/ Total Space: 531.51
Total Space: 531.51
D:\Desktop>ECHO/
D:\Desktop>EXIT /B
D:\Desktop>fsutil fsinfo statistics F:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo F:\
D:\Desktop>SET "CurrentDrive=F:\"
D:\Desktop>SET "CurrentDrive=F:
D:\Desktop>FOR /F "tokens=7 delims= " %A IN ('fsutil volume diskfree F:\ |FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%A"
D:\Desktop>Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "121982418944"
D:\Desktop>FOR /F %A IN ('powershell 121982418944 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=113.60498046875"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("113.60498046875") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=113" & SET "CurrentDrive_Temp2=60498046875"
D:\Desktop>SET "CurrentDrive_Temp3=60"
D:\Desktop>IF "4" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "60" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-FreeSpace=113.60"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F "tokens=6 delims= " %A IN ('fsutil volume diskfree F:\ |FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%A"
D:\Desktop>CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "214748360704"
D:\Desktop>FOR /F %A IN ('powershell 214748360704 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=199.999996185303"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("199.999996185303") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=199" & SET "CurrentDrive_Temp2=999996185303"
D:\Desktop>SET "CurrentDrive_Temp3=99"
D:\Desktop>IF "9" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "100" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-TotalSpace=200.00"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F %A IN ('powershell 200.00 - 113.60') DO Set "CurrentDrive-UsedSpace=%A"
D:\Desktop>Set "CurrentDrive-UsedSpace=86.4"
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 86.4 / 200.00 * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%A"
SET "CurrentDrive-UsedSpace-Percent2=%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-UsedSpace-Percent1=43"
SET "CurrentDrive-UsedSpace-Percent2=2"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 113.60 / 200.00 * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%A"
SET "CurrentDrive-FreeSpace-Percent2=%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-FreeSpace-Percent1=56"
SET "CurrentDrive-FreeSpace-Percent2=8"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>ECHO Drive Information For F:
Drive Information For F:
D:\Desktop>ECHO/ Used Space: 86.4 (43.2%)
Used Space: 86.4 (43.2%)
D:\Desktop>ECHO/ Free Space: 113.60 (56.8%)
Free Space: 113.60 (56.8%)
D:\Desktop>ECHO/ Total Space: 200.00
Total Space: 200.00
D:\Desktop>ECHO/
D:\Desktop>EXIT /B
D:\Desktop>fsutil fsinfo statistics G:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo G:\
D:\Desktop>SET "CurrentDrive=G:\"
D:\Desktop>SET "CurrentDrive=G:
D:\Desktop>FOR /F "tokens=7 delims= " %A IN ('fsutil volume diskfree G:\ |FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%A"
D:\Desktop>Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "214605746176"
D:\Desktop>FOR /F %A IN ('powershell 214605746176 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=199.867176055908"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("199.867176055908") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=199" & SET "CurrentDrive_Temp2=867176055908"
D:\Desktop>SET "CurrentDrive_Temp3=86"
D:\Desktop>IF "7" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "87" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-FreeSpace=199.87"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F "tokens=6 delims= " %A IN ('fsutil volume diskfree G:\ |FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%A"
D:\Desktop>CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "214748360704"
D:\Desktop>FOR /F %A IN ('powershell 214748360704 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=199.999996185303"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("199.999996185303") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=199" & SET "CurrentDrive_Temp2=999996185303"
D:\Desktop>SET "CurrentDrive_Temp3=99"
D:\Desktop>IF "9" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "100" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-TotalSpace=200.00"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F %A IN ('powershell 200.00 - 199.87') DO Set "CurrentDrive-UsedSpace=%A"
D:\Desktop>Set "CurrentDrive-UsedSpace=0.129999999999995"
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 0.129999999999995 / 200.00 * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%A"
SET "CurrentDrive-UsedSpace-Percent2=%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-UsedSpace-Percent1=0"
SET "CurrentDrive-UsedSpace-Percent2=0649999999999975"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 199.87 / 200.00 * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%A"
SET "CurrentDrive-FreeSpace-Percent2=%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-FreeSpace-Percent1=99"
SET "CurrentDrive-FreeSpace-Percent2=935"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>ECHO Drive Information For G:
Drive Information For G:
D:\Desktop>ECHO/ Used Space: 0.129999999999995 (0.0%)
Used Space: 0.129999999999995 (0.0%)
D:\Desktop>ECHO/ Free Space: 199.87 (99.9%)
Free Space: 199.87 (99.9%)
D:\Desktop>ECHO/ Total Space: 200.00
Total Space: 200.00
D:\Desktop>ECHO/
D:\Desktop>EXIT /B
D:\Desktop>fsutil fsinfo statistics H:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo H:\
D:\Desktop>fsutil fsinfo statistics I:\ | FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." 1>nul || CALL:GetDriveInfo I:\
D:\Desktop>SET "CurrentDrive=I:\"
D:\Desktop>SET "CurrentDrive=I:
D:\Desktop>FOR /F "tokens=7 delims= " %A IN ('fsutil volume diskfree I:\ |FINDSTR /C:"Total # of free bytes"') DO Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "%A"
D:\Desktop>Call:GetDriveInfo-Convert "CurrentDrive-FreeSpace" "906973425664"
D:\Desktop>FOR /F %A IN ('powershell 906973425664 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=844.684825897217"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("844.684825897217") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=844" & SET "CurrentDrive_Temp2=684825897217"
D:\Desktop>SET "CurrentDrive_Temp3=68"
D:\Desktop>IF "4" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "68" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-FreeSpace=844.68"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F "tokens=6 delims= " %A IN ('fsutil volume diskfree I:\ |FINDSTR /C:"Total # of bytes"') DO CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "%A"
D:\Desktop>CALL:GetDriveInfo-Convert "CurrentDrive-TotalSpace" "1000202432512"
D:\Desktop>FOR /F %A IN ('powershell 1000202432512 / 1024 / 1024 / 1024') DO SET "CurrentDrive_Temp=%A"
D:\Desktop>SET "CurrentDrive_Temp=931.51110458374"
D:\Desktop>FOR /F "Tokens=1-2 delims=." %A IN ("931.51110458374") DO SET "CurrentDrive_Temp1=%A" & SET "CurrentDrive_Temp2=%B"
D:\Desktop>SET "CurrentDrive_Temp1=931" & SET "CurrentDrive_Temp2=51110458374"
D:\Desktop>SET "CurrentDrive_Temp3=51"
D:\Desktop>IF "1" GEQ "5" SET /A "CurrentDrive_Temp3+=1"
D:\Desktop>IF "51" == "100" SET "CurrentDrive_Temp3=00" & SET /A CurrentDrive_Temp1+=1"
D:\Desktop>SET "CurrentDrive-TotalSpace=931.51"
D:\Desktop>EXIT /B
D:\Desktop>FOR /F %A IN ('powershell 931.51 - 844.68') DO Set "CurrentDrive-UsedSpace=%A"
D:\Desktop>Set "CurrentDrive-UsedSpace=86.83"
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 86.83 / 931.51 * 100') DO (
SET "CurrentDrive-UsedSpace-Percent1=%A"
SET "CurrentDrive-UsedSpace-Percent2=%B"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-UsedSpace-Percent1=9"
SET "CurrentDrive-UsedSpace-Percent2=32142435400586"
SET "CurrentDrive-UsedSpace-Percent2=!CurrentDrive-UsedSpace-Percent2:~0,1!"
SET "CurrentDrive-UsedSpace-Percent=!CurrentDrive-UsedSpace-Percent1!.!CurrentDrive-UsedSpace-Percent2!"
)
D:\Desktop>FOR /F "tokens=1-2 delims=." %A IN ('powershell 844.68 / 931.51 * 100') DO (
SET "CurrentDrive-FreeSpace-Percent1=%A"
SET "CurrentDrive-FreeSpace-Percent2=%B"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>(
SET "CurrentDrive-FreeSpace-Percent1=90"
SET "CurrentDrive-FreeSpace-Percent2=6785756459941"
SET "CurrentDrive-FreeSpace-Percent2=!CurrentDrive-FreeSpace-Percent2:~0,1!"
SET "CurrentDrive-FreeSpace-Percent=!CurrentDrive-FreeSpace-Percent1!.!CurrentDrive-FreeSpace-Percent2!"
)
D:\Desktop>ECHO Drive Information For I:
Drive Information For I:
D:\Desktop>ECHO/ Used Space: 86.83 (9.3%)
Used Space: 86.83 (9.3%)
D:\Desktop>ECHO/ Free Space: 844.68 (90.6%)
Free Space: 844.68 (90.6%)
D:\Desktop>ECHO/ Total Space: 931.51
Total Space: 931.51
D:\Desktop>ECHO/
D:\Desktop>EXIT /B
D:\Desktop>pause
Press any key to continue . . .
D:\Desktop>EXIT /B