Web Analytics

As many of you may have noticed from one of my previous post, (Monitor CPU and Memory Usage with Just One Click in Windows 7), I am doing a little research about Powershell.  The new script language that is shipped with Windows 7.

Today I want to show you how to find the top 10 of largest files in a computer using this new feature.

Presenting the Script

The idea behind the script is quite simple: sort files by size and show the 10 largest. I have chosen to show even the hidden ones.

@echo off
Powershell -noexit "Get-PSdrive  | where { $_.Used -gt 0 } | foreach { Get-ChildItem $_.Root -recurse -force  -ErrorAction SilentlyContinue | Select Name,DirectoryName, @{Label='Size';Expression={($_.Length/1GB).ToString('F04')}} | Sort Size -descending | select -first 10}"

As you see the script is quite simple, it will show the 10 biggest files of every drive connected to your computer.

Ed Note: This script will run for each drive/partition on your PC (including removable media like a DVD) so you may get 40 results (ordered by Drive, Size) if you have four drives/partitions on your PC. You can also see the top 5, 20 etc. files by changing first 10 to first 5 or first 20.

Create the Script

To do this, open notepad, press WinKey + R, type notepad, and press Enter.

Copy the script and you will end with something similar to this:

To force Notepad to save the file with a extension different from txt you have to use the hyphens as you see in the next picture.

Running the Script

Now if you double click over the file you will get something like this.

You will have to wait for the results, remember that the time need it by the utility is proportional to the number of files in the system.

The size is in GB. So, what are you waiting to know what are the files consuming your hard disks?

About Angel Luis

I am an Engineer of Telecommunications that love computers. My first computer was a Commodore 16kb, about 25 years ago and since then I am always fighting computers problems. Please visit my entries and ask me about whatever problem you have, I will be pleased to help you. My email is discoveryourpc [at] gmail [dot] com. You can follow me on twitter @agenlu or read my blog www.discoveryourpc.net

Free PC tips by email

Search Windows Guides


15 thoughts on “Find Top 10 Largest Files with Just One Click in Windows 7 [How To]”

  1. RSVR85 says:

    Great script. Takes a little long to receive the results but works good none the less.
    Is there anyway to sort the results into descending size order?

  2. SiNTAX says:

    Very nice, thank you.

    1. Angel says:

      Thank Sintax

  3. Angel says:

    The results are sort into descendig order in the same drive.

    It is incredible that powershell can do this things with only 1 sentence.

  4. Angel says:

    Thanks for the comment.

  5. RSVR85 says:

    Strange, the first time i ran it it didnt seem to have an order. Just re-ran it and it's sorted it correctly (as the script specifies too)…..
    Thanks for the reply Angel ;)

  6. Steve says:

    Is there a way of running this on mapped network drives?

    1. Angel says:

      Right now it will do in mapped network.

  7. Angel says:


  8. Jason Mig says:

     how can i take this script and have it email me the output ? I have the email piece down but when i put the script in for the body it fails

  9. Weavster says:

    It’s a nice idea, but not being able to see exactly where the files are located (DirectoryName column isn’t wide enough), makes finding the files later much more work than it should be. Thank God that Windows 7’s search feature isn’t as useless as it was in XP

    1. Angel says:

      Thanks. Maybe I can change that in other version

  10. M Anandakumar says:

    Thanks. It was very useful. 

  11. Frank Høvin says:

    “An empty pipe element is not allowed”.

    Could you people PLEASE stop posting nonworking code?!?!?!

  12. Frank Høvin says:

    Nice one. Post more scripts with errors in them, will you?

Comments are closed.

Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Subscribe now
Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Windows Guides on Facebook