Reputation: 1
I'm trying to run a Powershell command or CMD command, that count all files in 1 folder and its subfolder. I got a script that count all files, but it does not find hidden files. The problem I found was in my network share there was a folder that said 0 files, but when I go into the folder there are a lot of files in there.
Is there a way to get those files into the count?
I have tried a few Powershell command and CMD commands.
Get-ChildItem -Recurse -File | Measure-Object | %{$_.Count}
I can only get it to count files Windows can see, if a folder says 0 files but there are files in there, it does not count it.
Upvotes: 0
Views: 800
Reputation: 451
Use the force
PS> Get-ChildItem -Path c:\test | Measure-Object | Select-Object -ExpandProperty Count
16
PS> Get-ChildItem -Path c:\test -Force | Measure-Object | Select-Object -ExpandProperty Count
17
The -Force parameter on Get-ChildItem will force inclusion of hidden files
Upvotes: 1