使用Powershell命令进行文件计数

如何使用Powershell命令Get-ChildItem来计算特定文件夹(和所有子文件夹)中的所有文件? 与(Get-ChildItem <Folder> -recurse).Count也文件夹计数,这不是我想要的。 还有其他的可能性,快速计数非常大的文件夹中的文件?

有人知道有关Windows Powerhell的简短教程吗?

我会将结果传递给Measure-Object cmdlet。 使用(…)。如果没有符合条件的对象,则Count不会产生任何结果。

  $files = Get-ChildItem <Folder> -Recurse | Where-Object {!$_.PSIsContainer} | Measure-Object $files.Count 

在PowerShell v3中,我们可以执行以下操作来获取文件:

  Get-ChildItem <Folder> -File -Recurse 

在计数之前过滤文件:

 (Get-ChildItem <Folder> -recurse | where-object {-not ($_.PSIsContainer)}).Count