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.
![Find Top 10 Largest Files with Just One Click in Windows 7 [How To] windows 7 Notepad Find Top 10 Largest Files with Just One Click in Windows 7 [How To]](http://mintywhite.com/wp-content/uploads/2010/08/windows-7-Notepad.png)
Copy the script and you will end with something similar to this:
![Find Top 10 Largest Files with Just One Click in Windows 7 [How To] Windows 7 Notepad Largest Files Bat1 Find Top 10 Largest Files with Just One Click in Windows 7 [How To]](http://mintywhite.com/wp-content/uploads/2010/08/Windows-7-Notepad-Largest-Files-Bat1.png)
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.
![Find Top 10 Largest Files with Just One Click in Windows 7 [How To] Windows 7 Save As LargestFiles Bat Find Top 10 Largest Files with Just One Click in Windows 7 [How To]](http://mintywhite.com/wp-content/uploads/2010/08/Windows-7-Save-As-LargestFiles-Bat.png)
Running the Script
Now if you double click over the file you will get something like this.
![Find Top 10 Largest Files with Just One Click in Windows 7 [How To] Windows 7 Save As LargestFiles Output1 Find Top 10 Largest Files with Just One Click in Windows 7 [How To]](http://mintywhite.com/wp-content/uploads/2010/08/Windows-7-Save-As-LargestFiles-Output1.png)
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
Web | More Posts (48)
Search Windows Guides