You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell或Batch查找含12个以上文件的目录

找出包含12个以上文件的子目录

PowerShell 实现

Get-ChildItem -Directory | ForEach-Object {
    $fileCount = (Get-ChildItem -Path $_.FullName -File).Count
    if ($fileCount -gt 12) {
        $_.Name
    }
}
  • 若要指定目标目录,在Get-ChildItem -Directory后添加-Path "你的目标目录路径"即可。

Batch 脚本实现

@echo off
setlocal enabledelayedexpansion

for /d %%d in (*) do (
    set "count=0"
    for %%f in ("%%d\*") do (
        if not "%%~af"=="d" set /a count+=1
    )
    if !count! gtr 12 echo %%d
)
endlocal
  • 若要指定目标目录,将for /d %%d in (*)修改为for /d %%d in ("你的目标目录路径\*")即可。

内容的提问来源于stack exchange,提问作者Fabrizio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 10:24:14