I am counting files and folders inside a path, which has several files as well as folders.
I am using this:
dir -recurse | ?{ $_.PSIsContainer } | %{ Write-Host $_.FullName (dir $_.FullName | Measure-Object).Count }
Problem is that I want to know if the count contains sub folders. Also, the above command is not giving me the file count of the base folder.
e.g.
powershell\Copy_files.ps1powershell.txtsortbydate.ps1linux\New Text Document (2).txtNew Text Document.txt
For above file structure, I am getting :
linux 2
While I wanted:
Powershell 3 ( + 1 directory )
linux 2
This is my second attempt - Kind of ugly, but appears to do the job.