Al Lelopath
Al Lelopath

Reputation: 6778

How to count the number of files not of certain types

The code below counts the number of files of certain types in a directory and subdirectories:

$filetype = @("*.jpg", "*.jpeg","*.png","*.gif", "*.bmp")
$file_count = Get-ChildItem -Path $filepath -Include $filetype -Recurse -File | Measure-Object | %{$_.Count}
$output = "images: `t" + $file_count
Write-Output $output;

How would I count the number of all files that are not of these types?

Upvotes: 1

Views: 245

Answers (1)

It-Z
It-Z

Reputation: 2000

Just replace -Include $filetype with -Exclude $filetype

Upvotes: 1

Related Questions