小智 11
在 PowerShell 中,这是一种方法:
PS> Get-ChildItem -recurse | `
Where {$_.PSIsContainer -and `
@(Get-ChildItem $_.Fullname | Where {!$_.PSIsContainer}).Length -eq 1}
Run Code Online (Sandbox Code Playgroud)
在$_.PSIsContainer返回true用于显示目录和假的文件。的@()语法确保了表达式的结果是一个数组。如果其长度为 1,则该目录中只有一个文件。该示例还使用了嵌套管道,例如Get-ChildItem $_.Fullname | Where {...}在第一个 Where 脚本块中。
| 归档时间: |
|
| 查看次数: |
7430 次 |
| 最近记录: |