Site icon SumTips

Find Files Larger than a Specific Size with PowerShell & CMD

In this post I will show you how to find files that are larger than a specific size in a folder and all its sub-subfolders. My choice of command line utilities for this operation is going to be the built-in PowerShell and Command Prompt.

Windows PowerShell

The following command will find and list all files that are larger than 500MB in the entire C:\ drive.

Get-ChildItem C:\ -recurse | where-object {$_.length -gt 524288000} | Sort-Object length | ft fullname, length -auto

Explanation:

If you’re interested only in a specific file type, specify it this way in the command:

Get-ChildItem C:\ -recurse -include *.exe

Windows Command Prompt

In Command Prompt, forfiles command is used for batch processing a command on a file or set of files. The following command will find and list all files that are larger than 500MB in the C:\ drive.

forfiles /P C:\ /M *.* /S /C "CMD /C if @fsize gtr 524288000 echo @PATH @FSIZE"

Explanation:

To see list of other parameters and variables, simply enter forfiles /? in the command-line. This will help you to expand and format the output.

Exit mobile version