Count Files In A Directory
Need to count files in a directory? Try this one line of PowerShell:
(dir | where {$_.GetType() -match "fileInfo"} | measure-object).count
You can also add a -r parameter (-r means recursive) to the first dir
This comes in handy, though I do wish it was a little more succinct.
-
And of course you can substitute
lsfordirif you prefer, or evenGet-ChildItemif you’re feeling particularly masochistic. ↩︎