Bor*_*ard 18 powershell get-childitem
我有一个项目文件夹调用topfolder
,我想找到所有子文件夹中匹配某个模式的所有文件,例如,当文件夹包含foo
其名称中的任何位置时,我想列出其中的所有文件.
我尝试过类似的东西:
gci .\topfolder -rec -filter *foo*
Run Code Online (Sandbox Code Playgroud)
但它有两个问题:
foo
列出实际包含的文件(我想要foo类文件夹中的任何文件).然后我尝试了这个:
gci .\topfolder\*foo* -include *.*
Run Code Online (Sandbox Code Playgroud)
但这根本不起作用 - 显然,通配符只匹配路径的一个段,以便模式匹配topfolder\foobar
但不匹配topfolder\subfolder\foobar
.
我到目前为止找到的唯一方法是使用Get-ChildItem两次,如下所示:
gci .\topfolder -rec -include *foo* | where { $_.psiscontainer } | gci
Run Code Online (Sandbox Code Playgroud)
这工作,但它似乎是一种浪费调用gci
两次,我希望我只是没有找到类似的权利通配符表达式-Path
,-Filter
或者-Include
.
最好的方法是什么?
Sha*_*evy 19
我会使用Filter参数而不是Include,它会执行很多胖
gci .\topfolder -rec -filter *foo* | where { $_.psiscontainer } | gci
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
41849 次 |
最近记录: |