Sorting folders by size and retaining object…ness

$FolderSizes = foreach ($Folder in $Folders) { Get-ChildItem $Folder.FullName -Recurse | Measure-Object Length -Sum } $BigFolder = $FolderSizes | Sort-Object -Property Sum -Descending | Select-Object -First 1 

That’s really bad I know and yes I realize this is why formal education helps. Some of you are rightfully thinking.

So while I found the largest folder, I’ve mutated from an object into a MeasureInfo and I lose information like the path that I need to reference next, which would be to copy files from within said largest folder.

Should I be trying to make a custom object (would be new stuff to me), and then set the path and size separately? Also any advice on how else to pipe or structure this would be super appreciated.

Any help is welcomed and thanks for reading.

submitted by /u/doomjuice
[link] [comments]

Leave a Reply