2017-10-24 6 views
0

다음 작업을 수행하는 배치 파일이 있습니다.남은 GB 공간의 FSUTIL

echo Server 1 C:\>>output.txt 
fsutil volume diskfree \\IPISHERE\d$>>output.txt 
echo ---------------------------------------------------------- >>output.txt 

이는

Total # of free bytes  : 71942455296 
Total # of bytes    : 131623546880 
Total # of avail free bytes : 71942455296 

어떤 하나 개의 도움이 그래서 GB를하여 변환 할 수 있습니다하십시오

같은 데이터를 표시?

+0

은'SET/A' 명령 32 개 비트 정수 산술 연산 만 수행 할 수 있습니다. 최대 값은 2,147,483,647입니다. – Squashman

+0

정밀도가 필요하지 않다면 6LS 숫자를 버리거나 6LS 숫자를 버리고 반올림하면됩니다. 그런 다음 필요에 따라 적절한 위치에 소수점을 삽입하십시오. – RGuggisberg

답변

0
@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 
) 

출력 예 :

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