windows files per folder

I have a root folder containing a number of sub folders. I want a way to specify the root folder, and it produce a summary of how many files are in each sub folder. Is this possible? There may be a few levels of sub directory in each sub folder.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nadav SolomonCommented:
function getSubDirs($dir)
    "$dir contains $((getNumberOfFiles($dir)).count) files"
    dir $dir -Directory | %{

function getNumberOfFiles($dir)
    dir $dir -File |measure |select count

getSubDirs C:\Windows

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pma111Author Commented:
hi nadav what scripting language is the above written in? is it a vbs?
Nadav SolomonCommented:
powershell, you used a tag of powershell.
Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

pma111Author Commented:
Nadav SolomonCommented:
if you want vbscript (just for the fun here it is)
Set fso = WScript.CreateObject("Scripting.Filesystemobject")


sub getDirs(path)
	Set folder = fso.GetFolder(path)
	On Error Resume Next 
	WScript.Echo path & " contains " & folder.Files.Count & " files."
	If Err.Number <> 0 Then
		WScript.Echo path & " " & Err.Description
	End If 
	For Each fld In folder.SubFolders
End sub 

Open in new window

You are most welcome.
Nadav SolomonCommented:
Thanks for the feedback
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.