Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8600697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:40:32+00:00 2026-06-12T01:40:32+00:00

Does anyone know how to display only 2 characters past a decimal point. Example:

  • 0

Does anyone know how to display only 2 characters past a decimal point.

Example:
19.123948493114 turns into 19.12

Can’t use %variable:~5% because the number before the decimal changes so sometimes it will be 19 other times it will be 123451213.12345123

Both need to only display 2 characters past the decimal point

-= EDIT =-
Here is the current script I have.

@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

The Issue?
one of the drives for no reason at all seems to want to not cut off.

My Results:

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

My Shortened Script Debug File. I cut off the entire function for the C: drive and everything after the G: drive because that is the drive that is the problem, and i can’t post more then 30k characters 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 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:40:33+00:00Added an answer on June 12, 2026 at 1:40 am

    New answer

    I was in the process of developing an answer that rounds the result properly when I saw your edited post.

    If you are going to use PowerShell, you might as well really use it. I found this Windows PowerShell Tip of the Week that shows how to format a number.

    The whole script would probably best be done with PowerShell, but I don’t have any expertise with that language. So I threw together this hybrid script. There is probably a better way to do even the hybrid solution, but this works. It is much faster than your original because it reduces the number of PowerShell calls to one per drive.

    @echo off
    setlocal enableDelayedExpansion
    cls
    for /f "tokens=1*" %%A in ('fsutil fsinfo drives') do for %%C in (%%B) do (
      fsutil fsinfo statistics %%C |FINDSTR /I /C:"The FSUTIL utility requires a local NTFS volume." >nul || CALL:GetDriveInfo %%C
    )
    exit /b
    
    :GetDriveInfo
    set "free="
    for /f "tokens=2 delims=:" %%A in ('fsutil volume diskfree %~1') do (
      if not defined free (set free=%%A) else (set total=%%A & goto :break)
    )
    :break
    set "cmd=$used=%total%-%free%;$usedP=$used/%total%;$used=$used/1073741824;$freeP=%free%/%total%;$free=%free%/1073741824;$total=%total%/1073741824;"{0:N2}" -f $used;"{0:P1}" -f $usedP;"{0:N2}" -f $free;"{0:P1}" -f $freeP;"{0:N2}" -f $total"
    set i=0
    for /f "delims=" %%N in ('echo !cmd!^|powershell -Command -') do (
      set /a i+=1
      set n!i!=%%N
    )
    set "drive=%~1"
    echo Drive Information For %drive:\=%
    echo Used Space: %n1% (%n2: =%)
    echo Free Space: %n3% (%n4: =%)
    echo Total Space: %n5%
    exit /b
    

    I don’t like using FSUTIL because it requires admin rights, it is restricted to NTFS volumes, and your script is calling it twice per drive, plus one additional time.

    I think it is simpler and better to use a single WMIC call instead. This solution is not restricted to NTFS drives.

    Edit – I simplified the powershell code by learning how to properly format an entire string with multiple variable references. I could do the same for the previous FSUTIL based solution

    I still post-process the PowerShell output to remove the space that PowerShell inserts before the % sign.

    @echo off
    setlocal enableDelayedExpansion
    cls
    set "printCmd=;"Used Space: {0:N2} ({1:P1}^)`nFree Space: {2:N2} ({3:P1}^)`nTotal Space: {4:N2}" -f $used,$usedP,$free,$freeP,$total"
    for /f "skip=1 tokens=1-3 delims= " %%A in ('wmic logicalDisk get deviceId^, freeSpace^, size') do if "%%C" neq "" (
      set "defineVarsCmd=$used=%%C-%%B;$usedP=$used/%%C;$used=$used/1073741824;$freeP=%%B/%%C;$free=%%B/1073741824;$total=%%C/1073741824"
      echo Drive Information For %%A
      for /f "delims=" %%S in ('echo !defineVarsCmd!!printCmd!^|powershell -Command -') do (
        set "str=%%S"
        echo !str: %%=%%!
      )
      echo(
    )
    

    I’m sure someone who knows PowerShell could easily strip out the batch portion from the above and give an even shorter pure PowerShell script.

    Original Answer

    Note – This original answer truncates after the 2nd decimal digit. It does not do any rounding

    Break up the number into 2 parts, the whole number and the fractional number. "00" is appended to the fractional portion to make sure it has at least 2 digits. Then put the number back together, truncating the fractional portion to 2 digits in the process.

    The following code expects a decimal number as the first and only parameter.

    @echo off
    setlocal
    set num=%1
    set part1=%num:.=&rem %
    set "part2=%num:*.=%"
    if "%part2%" neq "%num%" (set "part2=%part2%00") else set "part2=00"
    set "num=%part1%.%part2:~0,2%
    echo num=%num%
    

    The tricky part is to get the whole number portion. I use variable expansion search and replace to inject a REM command into the SET statement.

    If num =19.123, then set part1=%num:.=&rem % becomes set part2=19&rem 123

    Native batch method to round a decimal number to 1/100 precision

    I like your use of FOR /F to parse the number into the whole and fractional portion. But your original code has potential problems with the rounding logic.

    I haven’t diagnosed exactly why your one drive letter fails, but there is a problem in your code with a value like 1.09. SET /A will interpret 09 as hexadecimal and will throw an error because 9 is not a valid hex digit. Your method also has problems if the whole number portion is missing before the ., though that should never happen in your situation.

    I don’t think either of those problems are causing your particular failure, but I thought I would provide a pure batch method that should reliably round any decimal number to 1/100 precision.

    Again, the script expects a decimal number as the first and only parameter.

    @echo off
    setlocal
    for /f "tokens=1,2 delims=." %%A in ("0%~1") do (
      set "part1=%%A"
      set "part2=1%%B000"
    )
    for /f "tokens=* delims=0" %%N in ("%part1%1") do (
      set /a "part1=%%N/10, roundup=%part2:~3,1%/5, part2=%part2:~0,3%+roundup, part1+=(part2/200)"
    )
    set "num=%part1%.%part2:~1,2%"
    echo num=%num%
    

    Finally, here is another version that takes the number of decimal digits to preserve as a 2nd parameter. It should always work as long as the input number is less than 200000000 and the requested number of decimal digits is less than or equal to 9.

    @echo off
    :roundDecimal  number  precision
    setlocal enableDelayedExpansion
    for /f "tokens=1,2 delims=." %%A in ("0%~1") do (
      set "part1=%%A"
      set "part2=1%%B0000000000"
    )
    set /a len=%~2+1
    for /f "tokens=* delims=0" %%N in ("%part1%1") do (
      set /a "part1=%%N/10, roundup=!part2:~%len%,1!/5, part2=!part2:~0,%len%!+roundup"
      set /a "part1+=(!part2:~0,1!/2)"
    )
    if %~2 gtr 0 (set num=%part1%.!part2:~1,%~2!) else set num=%part1%
    echo num=%num%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of any websites, or (preferably) downloadable packages that you can use
Does anyone know how can I format a select statement datetime value to only
Does anyone know how can I display an image for the browsers which don't
Does anyone know if Fiddler can display the raw SOAP messages for ASMX web
Does anyone know the display formatter that I would need to add to the
Does anyone know how to display a percentage format based on the locale using
Does anyone know of a way to make an AIR app display over top
Does anyone know of a free tool, similar to what is built into Visual
Does anyone know how to do this? I know how to display a single
Does anyone know a way to display code in Microsoft Word documents that preserves

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.