且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Powershell 测试文件夹是否为空

更新时间:2023-11-28 19:04:16

试试这个...

$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.