Finding folders on PC with fewer than five files inside

Xploit Machine

Well-known member
Joined
Nov 29, 2022
Messages
783
Reaction score
73
Get-ChildItem -Recurse -Directory |
ForEach {
[pscustomobject]@{fullname=$_.fullname; numfiles=($_ | Get-ChildItem -File | Measure).count}
}
Get-ChildItem $env:est\ -Directory -Recurse|
Where {$_.GetFiles().Count -gt 4} |
ForEach-Object{
[pscustomobject]@{
FullName = $_.Fullname
FileCount = $_.GetFiles().Count
}
}

I'm bad in coding .. I prefer to use WinDirStat 🤭
 

Vote:

King Mustard

Member
Joined
Aug 8, 2021
Messages
12
Reaction score
1
I'm bad in coding .. I prefer to use WinDirStat 🤭
Thank you for that.

For background, a family member has a massive photos directory that contains hundreds of folders, each containing images.

She wants to tidy the directory by only keeping folders that have five or more images in them.

For folders with less than five images inside, she wants to move those images to the root then delete the folders, but I can do those manually once we identify the folders in question.
 

Vote:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top