[英]Powershell Search Through Directory Tree with a combination of patterns
我需要通過Powershell在具有某些模式的目錄樹中進行搜索。 我應該如何將所有模式放在一起,以便poweshell可以遞歸搜索目錄樹。
起點:F:\\ Production
模式:
使用此模式組合從起點循環遍歷整個目錄樹。
Starting Point: F:\Production
F:\Production
|---AAA
| |___Archive
| |___80186
| |___All
| |___POM
| |___xxx
| | |___PML*****PROD
| | |___XML
| | |___00.XML
| | |___01.XML
| | |___02.XML
| |___yyy
| |___PML*****PROD
| |___XML
| |___00.XML
| |___01.XML
| |___02.XML
|___BBB
|___CCC
|___DDD
您已經確定了步驟(要使用的“算法”。)
現在,只需使用管道即可實現它們:)
$XMLFiles = Get-ChildItem -Path $RootDir -Filter "POM" -Directory -Recurse | Where-Object {
$_.Parent.Name -eq 'All' -and $_.FullName -notlike "*\Archive\*"
} | Get-ChildItem -Directory -Filter "PML*PROD" | Get-ChildItem -Directory -Filter "XML" | Get-ChileItem -Filter "*.xml" | Where {$_.Name -ne "00.xml"}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.