gpt4 book ai didi

Powershell Get-Childitem 排除目录中的子目录

转载 作者:行者123 更新时间:2023-12-03 18:42:49 38 4
gpt4 key购买 nike

大家好,我的文件夹结构如下

D:\Exclude
Include
Include1
Exclude
Include

我需要的是我想过滤目录 Include1\Exclude 这是我试过的但不起作用

$Path ="D:\Exclude"
$DirList = Get-ChildItem -Path "$Path" -Recurse | where {$_.DirectoryName -ne "D:\Exclude\Include1\Exclude"}
$DirList

最佳答案

使用 .FullName 属性而不是目录名称,就像这样。

 dir $path -Recurse  | measure | select Count

Count
-----
4

PS C:\users\Stephen> dir $path -Recurse | ? FullName -ne "R:\Exclude\Include1\Exclude" |
>> measure | select Count

Count
-----
3

关于Powershell Get-Childitem 排除目录中的子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41744714/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com