windows - 使用 Powershell 计算文件夹

标签 windows shell powershell scripting

有没有人知道 powershell 2.0 命令/脚本来计算特定文件夹中的所有文件夹和子文件夹(递归;无文件)(例如 C:\folder1\folder2 中所有子文件夹的数量) ?

此外,我还需要所有“叶”文件夹的数量。换句话说,我只想计算没有子文件夹的文件夹。

最佳答案

在 PowerShell 3.0 中,您可以使用目录开关:

(Get-ChildItem -Path <path> -Directory -Recurse -Force).Count

关于windows - 使用 Powershell 计算文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12934106/

相关文章:

windows - 如何区分 Windows 权限

c++ - 我的程序在 Windows 机器上崩溃但在 Linux 上运行正常

android - 通过应用程序运行 shell 命令..无法正常工作

linux - 如何在 bash shell 中在另一个文件的开头插入一个文件

powershell - 在Powershell中转义冒号

powershell - 是否可以在Powershell多行命令中使用注释?

windows - 如何批量删除 stashes?

windows - 用于打开多个 CMD 窗口的批处理脚本的奇怪行为

linux - spawn_id : spawn id exp6 not open

powershell - 具有Mir参数的Robocopy最大量距