本帖最后由 buyiyang 于 2023-8-21 11:54 编辑
加一个可以右对齐的功能- @echo off
- for /f "tokens=1-4" %%a in ('"pecmd.exe team find C:\=?,a^|ifex C:\=?,b^|calc c=%%a%%/1g#2F^|calc d=(%%a%%-%%b%%)/1g#2F^|calc e=%%b%%/1g#2F^|calc f=(%%a%%-%%b%%)*100/%%a%%#0F^|writ -,$+0,%%c%% %%d%% %%e%% %%f%%"') do set "总空间=%%a"&set "已用空间=%%b"&set "剩余空间=%%c"&set "使用率=%%d"
- set "space= "
- set "a=%总空间%gfedcba9876543210"
- set /a n=0x%a:~16,1%,m=16-n
- for /l %%i in (1,1,%m%) do call set "space1=%%space1%% "
- set "a=%剩余空间%gfedcba9876543210"
- set /a n=0x%a:~16,1%,m=18-n
- for /l %%i in (1,1,%m%) do call set "space2=%%space2%% "
- set "a=%已用空间%gfedcba9876543210"
- set /a n=0x%a:~16,1%,m=18-n
- for /l %%i in (1,1,%m%) do call set "space3=%%space3%% "
- echo,%space% C盘%space%%总空间%%space1%%剩余空间%%space2%%已用空间%%space3%%使用率%%%
- echo,%space%磁盘%space%总空间%space%剩余空间%space%已用空间%space%使用率
- echo, ----------------------------------------------------------------------------------
- pause>nul
复制代码
|