≡ Menu

How to find large files

In Windows, if one wants to find which files are consuming most of the space on the disk, it can be found easily using explorer. Just sort list of the files based on the size attribute. But what if we need to find the large sized files from command line? How can we do this?

We can find this using windows commands, without needing any third party tools.  We can do this using forfiles command.

Find files with size of 1 MB or more.

forfiles /S /M * /C "cmd /c if @fsize GEQ 1048576 echo @path"

Example:

c:\users\mike>forfiles /S /M * /C "cmd /c if @fsize GEQ 1048576 echo @path"

"c:\Users\mike\AppData\Local\Microsoft\MSOIdentityCRL\Tracing\msoidLiteTrace{9317BCB6-314B-442F-A5DA-9BC2BEBC271D}.txt"
"c:\Users\mike\Documents\work\May-2014.txt"
"c:\Users\mike\Documents\work\tmp\feed.txt"
"c:\Users\mike\Documents\work\tmp\syslog.txt"

This command prints the complete file path. If you need to print just the file name, you can use @file in place of @path.

Command to find files with size of more than 100MB

forfiles /S /M * /C "cmd /c if @fsize GEQ 104857600 echo @path"

Find files with size 1 GB or more.

forfiles /S /M * /C "cmd /c if @fsize GEQ 1073741824 echo @path"

As shown above, this command allows us to find files having size more than a given value. It’s not useful if someone wants to find the largest 10 files in a folder. I could not find a way to do this using windows native commands. If you know of any way to do this, please let others know by adding comment below.

9 comments… add one
  • Robert

    When running it from the root of a server I get “Error: The filename or extension is too long.” message.

    I have not yet, but I will try running is several folder in from a data share.
    I also created a batch file to run it and where I placed the bat was not in the path, so I had to precede the command with the path. I also changed from *.txt to *.* as I want to see all files over a gig in size.
    Thanks!

    • admin

      Thanks. I updated the commands to consider all file types.

  • Teja

    What should be the command to find top ‘x’ files. For example, I need to find top 10 big files on my system.

  • Kala Sha Jahan

    works, but only searches the current user profile. can it search every user profile?

    • Srini

      If you run the command from C:\, you can search across all user profiles.

  • albina elvira

    The path you entered, is too long. Enter a shorter path
    File Name could not be found. Check the spelling of the filename,
    and verify that the file location is correct.

  • Arcindo

    O meu resultado foi este http://i.imgur.com/wD8Oycv.png

    • J C

      That’s powershell… not Command Prompt.

  • NotABot

    For those wanting top 10 files, redirect output to a text file such as
    forfiles /S /M * /C “cmd /c if @fsize GEQ 1073741824 echo @path > bigfiles.txt”

    You can then open in excel and sort or use text editor to weed out the files you don’t want

Leave a Comment