使用 Powershell 命令进行文件计数 [英] File counting with Powershell commands
问题描述
如何使用 Powershell 命令 Get-ChildItem 计算特定文件夹(和所有子文件夹)中的所有文件?使用 (Get-ChildItem <Folder> -recurse).Count
也计算文件夹,这不是我想要的.是否有其他方法可以快速计算非常大文件夹中的文件?
How can I count all files in a specific folder (and all subfolders) with the Powershell command Get-ChildItem?
With (Get-ChildItem <Folder> -recurse).Count
also the folders are counted and this is not that what I want. Are there other possibilities for counting files in very big folders quickly?
有人知道关于 Windows Powerhell 的简短而好的教程吗?
Does anybody know a short and good tutorial regarding the Windows Powerhell?
推荐答案
我会将结果通过管道传送到 Measure-Object
cmdlet.如果没有符合您的条件的对象,则使用 (...).Count 不会产生任何结果.
I would pipe the result to the Measure-Object
cmdlet. Using (...).Count can yield nothing in case there are no objects that match your criteria.
$files = Get-ChildItem <Folder> -Recurse | Where-Object {!$_.PSIsContainer} | Measure-Object
$files.Count
在 PowerShell v3 中,我们可以执行以下操作来仅获取文件:
In PowerShell v3 we can do the following to get files only:
Get-ChildItem <Folder> -File -Recurse
这篇关于使用 Powershell 命令进行文件计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!