Q. Is there an easy way to list the largest files in a folder structure using PowerShell?
December 4, 2010
A. Sometimes you want to just know the largest files in a folder structure. I found this easy command that goes through all subfolders of the selected folder and lists the top specified number (in my case, 10).
PS C:Usersjohn> Get-ChildItem d:multimedia -recurse | Sort-Object length -descending | select-object -first 10 | ft name, length -wrap -auto Name Length---- ------Lord of the Rings - Return of the King.wmv 4014341867Meet Joe Black.wmv 3589038391Lord of the Rings - Two Towers.wmv 3557926091Lord of the Rings - Fellowship of the Ring.wmv 3527093725Titanic.wmv 3507283683The Abyss.wmv 3431843091Harry Potter - Year 2.wmv 3196511467The Dark Knight.mp4 3190127918Avatar.wmv 3183343677Harry Potter - Year 4.wmv 3134166063
You could customize the output to match whatever you need, but it's a great way to quickly see the largest files in a large folder structure. In my example, I had a Movies subfolder, which is where all these files resided. (Whenever I buy a DVD, I rip it to this folder so I have easy access). Lord of the Rings, what a disk space killer . And yes I had considered renaming Harry Potter and Titanic movies to more manly movies like "Death Ninja strikes back" in the output, but I just didn't have the energy. I'll just say that they're my wife's and son's films .
About the Author
You May Also Like