目录和子目录CMD中所有File Ext的计数

问题描述 投票:0回答:1

如何修改下面的 CMD 行以包含所有子文件夹?

cmd /c ">NUL (@for %I in (*) do @set /a ext[%~xI] += 1) & set ext["

我可以在以下位置添加

/s
开关吗:

所需的输出如下所示,但将包括所有子文件夹

ext[.pdf]=187
ext[.txt]=2
ext[.zip]=1

谢谢

cmd
1个回答
0
投票

如果您使用的是受支持的 Windows 系统,则可以使用 PowerShell。您可以使用此

cmd
命令。

powershell -NoLogo -NoProfile -Command ^
    "Get-ChildItem -Recurse -File | Group-Object -Property Extension | ForEach-Object { \"ext[$($_.Name)]=$($_.Count)\" }"

如果您使用 PowerShell 控制台,那就有点不那么神秘了。

Get-ChildItem -Recurse -File | Group-Object -Property Extension | ForEach-Object {"ext[$($_.Name)]=$($_.Count)"}
© www.soinside.com 2019 - 2024. All rights reserved.