rem 以下代码出自COPILOT: @ echo off rem 创建一个空的数组,用来存储扩展名和出现次数 setlocal enabledelayedexpansion set "exts=" rem 遍历当前文件夹下的所有文件,获取扩展名 for %%f in (*) do ( rem 如果扩展名已经存在于数组中,就将对应的次数加一 rem 如果扩展名不存在于数组中,就将其添加到数组中,并将次数设为一 set "found=0" for %%e in (%exts%) do ( if "%%~xe"=="%%~xf" ( set /a "count_%%~xe+=1" set "found=1" ) ) if "!found!"=="0" ( set "exts=!exts! %%~xf" set "count_%%~xf=1" ) ) rem 初始化最大次数和最多的扩展名 set "max=0" set "most=" rem 遍历数组中的所有扩展名,找出出现次数最多的那个 for %%e in (%exts%) do ( if !count_%%e! gtr !max! ( set "max=!count_%%e!" set "most=%%e" ) ) rem 显示结果 echo The most frequent extension is %most% with %max% occurrences.