@echo off
setlocal enabledelayedexpansion
dir *.bat /-c >temp.tmp
find "/" temp.tmp>temp2.tmp
del temp.tmp
for /f "delims=: tokens=2" %%i in (temp2.tmp) do (
set aa=%%i
set aa=!aa: =_!
echo !aa!>>temp.tmp
)
del temp2.tmp
set ncount=0
set nsum=0
for /f "delims=_ tokens=2" %%j in (temp.tmp) do (
set /a nsum=!nsum!+%%j
set /a ncount=1+!ncount!
)
del temp.tmp
set /a nsum=!nsum!/!ncount!
echo 平均数是!nsum!
保存为cmd文件运行即可输出结果
不要保存为bat,否则计算中会把自己的大小也算上
追问一个文件的容量是20GB.所以可能有点问题.能换算成MB吗?
无效数字。数字精确度限为 32 位。
平均数是524288000
请按任意键继续. . .
追答你是32bit的windows?变量长度有限制了
@echo off
setlocal enabledelayedexpansion
dir *.bat /-c >temp.tmp
find "/" temp.tmp>temp2.tmp
del temp.tmp
for /f "delims=: tokens=2" %%i in (temp2.tmp) do (
set aa=%%i
set aa=!aa: =_!
echo !aa!>>temp.tmp
)
del temp2.tmp
set ncount=0
set nsum=0
for /f "delims=_ tokens=2" %%j in (temp.tmp) do (
set /a nsum=!nsum!+%%j/1048576
set /a ncount=1+!ncount!
)
del temp.tmp
set /a nsum=!nsum!/!ncount!
echo 平均数是!nsum!
请及时采纳