Enhance Get-ChildItem so that it can filter recused directories names. #15831
Replies: 2 comments 3 replies
-
Main confusion here is what is "directory names" - short name or path? |
Beta Was this translation helpful? Give feedback.
-
I could think of introducing a new function whose sole purpose it is to return a list of paths via recursion e.g. Get-ParentItem. That path-list can then be passed to Get-ChildItem to retrieve the files. But Get-ChildItem could be used for both e.g:
Note that -Include/Exclude arguments can't be used to filter out directories. Therefore the need for new -RecurseInclude/Exclude arguments |
Beta Was this translation helpful? Give feedback.
-
Enhance Get-ChildItem so that it can filter recused directories names.
Add 2 switches: -RecuseInclude & -RecurseExclude that operate on the recused directory names similar to how the -Include & -Exclude currently operate on the recused filenames.
Example: I want to find *.cs files in all subdirectories named
src*
but exclude any subdirectories names ending with*test
or*unit
Get-ChildItem -Recurse -RecurseInclude "src*" -RecurseExclude "*test","*unit" -Path ".\*" -Include "*.cs" -Exclude "test*"
Beta Was this translation helpful? Give feedback.
All reactions