我只想从Get-ChildItem中过滤掉叶子节点(文件夹),那些不包含任何其他文件夹的节点。
以下是我当前的查询:
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*"发布于 2016-08-10 21:56:48
他走在正确的道路上,但只是忘记了第二个Get-ChildItem命令的-Directory。
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName -Directory) }注意:如果你想找到隐藏的文件夹,你必须在下面这行中的两个Get-ChildItem命令上使用-Force。
发布于 2016-08-10 16:47:04
您需要另一个筛选器来确定文件夹中是否包含任何内容:
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName) }发布于 2016-09-07 18:55:44
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" |?{$_.psiscontainer}
https://stackoverflow.com/questions/38868231
复制相似问题