Reputation: 2301
I want to search particular string on multiple files, here the command will do. This command will search all folders within AMT_Project. Now I want to skip folder Data Within AMT_Project folder. How can I do that ?
PS E:\User\AMT_Project> Get-ChildItem -recurse | Select-String -pattern "+@QWEAz" -SimpleMatch | group path | select name
Folder structure
Upvotes: 1
Views: 654
Reputation: 58931
You could invoke Get-ChildItem twice. The first time, you get all items from the E:\User\AMT_Project
directory, then you exclude the Data
folder using the Where-Object cmdlet and finally use the second Get-ChildItem cmdlet with the -Recurse
switch to retrieve the files recursively:
Get-ChildItem 'E:\User\AMT_Project' | Where-Object Name -ne 'Data' | Get-ChildItem -Recurse
You could also retrieve all items recursively first and filter them:
Get-ChildItems 'E:\User\AMT_Project' -Recurse | Where-Object FullName -NotMatch 'E:\\User\\AMT_Project\\Data\\.*'
Upvotes: 1