Skip navigation

Q. Is there an easy way to list the largest files in a folder structure using PowerShell?

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:\Users\john> Get-ChildItem d:\multimedia -recurse | Sort-Object length -descending | select-object -first 10 | ft n
ame, length -wrap -auto
 
Name                                               Length
----                                               ------
Lord of the Rings - Return of the King.wmv     4014341867
Meet Joe Black.wmv                             3589038391
Lord of the Rings - Two Towers.wmv             3557926091
Lord of the Rings - Fellowship of the Ring.wmv 3527093725
Titanic.wmv                                    3507283683
The Abyss.wmv                                  3431843091
Harry Potter - Year 2.wmv                      3196511467
The Dark Knight.mp4                            3190127918
Avatar.wmv                                     3183343677
Harry 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 Smile. 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 Smile.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish