While Get-ChildItem
does have an -Exclude
parameter, it only operates on the file-name part, not on the full path.
Therefore, you must perform the exclusion filtering after the fact, using the negated form of -like
, the wildcard matching operator
pylint ((Get-ChildItem -Recurse -Name -Filter *.py) -notlike 'exclude_dir/*')
Note the use of -Filter
rather than -Include
, which speeds up the operation, because filtering happens at the source rather than being applied by PowerShell after the fact.
However, given that you're seemingly only excluding a single top-level folder, you could try:
pylint (Get-ChildItem -Recurse -Path * -Filter *.py -Exclude exclude_dir)
Note that I've omitted -Name
in this case, because it wouldn't work properly in this scenario. As a result, the matching files are implicitly passed as full paths to pylint
.
As of PowerShell 7.0, -Name
exhibits several problematic behaviors, which are summarized in this answer.