Windows Guides Feed

PowerShell Icon Find Top 10 Largest Files with Just One Click in Windows 7 [How To]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.

windows 7 Notepad Find Top 10 Largest Files with Just One Click in Windows 7 [How To]

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

Windows 7 Notepad Largest Files Bat1 Find Top 10 Largest Files with Just One Click in Windows 7 [How To]

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.

Windows 7 Save As LargestFiles Bat Find Top 10 Largest Files with Just One Click in Windows 7 [How To]

Running the Script

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

Windows 7 Save As LargestFiles Output1 Find Top 10 Largest Files with Just One Click in Windows 7 [How To]

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?



 Find Top 10 Largest Files with Just One Click in Windows 7 [How To]

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




Comments

  • http://mintywhite.com RSVR85

    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?

  • SiNTAX

    Very nice, thank you.

    • http://twitter.com/agenlu Angel

      Thank Sintax

  • http://discoveryourpc.net Angel

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

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

  • http://discoveryourpc.net Angel

    Thanks for the comment.

  • http://mintywhite.com RSVR85

    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 ;)

  • Steve

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

    • http://twitter.com/agenlu Angel

      Right now it will do in mapped network.

  • http://twitter.com/agenlu Angel

    Thanks

  • Jason Mig

     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

  • Weavster

    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

    • http://discoveryourpc.net Angel

      Thanks. Maybe I can change that in other version

  • M Anandakumar

    Thanks. It was very useful. 


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

Enter your email address:
 

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

Submit Your Tip
Submit your computer tip to us; receive full credit for all published tips

Windows Guides on Facebook