使用 Powershell 命令进行文件计数 [英] File counting with Powershell commands

查看:45
本文介绍了使用 Powershell 命令进行文件计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆