回复 3# hnfeng
要速度就不要分开来 比如一次性处理所有数据
或者
不要用powershell ,按启动1秒来算 ,换成其他的话 ,每次调用应该能快半秒
或者
不要用call ,能够快一点点的时间- @echo off&setlocal EnableDelayedExpansion&cd /d "%~dp0"&title %~nx0
-
- echo 磁盘 剩余 总大小
- for /f "tokens=1,2,3 delims= " %%a in ('wmic logicaldisk get Caption^,Size^,FreeSpace ^|findstr [0-9] ') do (
- set "str=!str! %%a %%b %%c?"
- )
-
- echo,!str!|powershell -c "$j=$input -split '\?';$j|foreach{[regex]::replace($_,'\d+',{$i=[decimal]$args[0].value;('TB',1tb),('GB',1gb),('MB',1mb),('KB',1kb),('B',1)|foreach{if($i -ge $_[1]){'{0,7}' -f (''+[math]::Truncate($i/$_[1])+$_[0]);$i=0;}}})}"
-
- pause
- endlocal&exit/b
复制代码
|