Powershell 测试文件夹是否为空 [英] Powershell test if folder empty

查看:125
本文介绍了Powershell 测试文件夹是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Powershell 中,如何测试目录是否为空?

In Powershell, how do I test if a directory is empty?

推荐答案

试试这个...

$directoryInfo = Get-ChildItem C:\temp | Measure-Object
$directoryInfo.count #Returns the count of all of the objects in the directory

如果$directoryInfo.count -eq 0,那么你的目录是空的.

If $directoryInfo.count -eq 0, then your directory is empty.

这篇关于Powershell 测试文件夹是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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