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 top big files from CMD using forfiles command. We would not need to download any third party tools,
Run the command below to find files with size greater than specified value.
forfiles /S /M * /C "cmd /c if @fsize GEQ SizeInBytes echo @path"
c:\>forfiles /S /M * /C "cmd /c if @fsize GEQ 1048576 echo @path" "c:\data\May-2014.txt" "c:\data\work\tmp\feed.txt" "c:\data\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.