Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried this command:

dir /s /a:-d /o:-s /b

However this command gives the biggest file hierarchy wise. For example, first it gives the biggest file in the main folder and listed out other files, then the biggest file in the subfolder. I need the biggest file on the top whether it is in the folder or subfolder.

share|improve this question
you can view the folders and subfolders through following command tree (drive letter :) e.g tree c: – BlueBerry - Vignesh4303 Jul 31 '12 at 7:40

PowerShell can do this very easily:

Get-ChildItem -Path "C:\SomeParentDirectory" -Recurse | Sort-Object -Descending Length
share|improve this answer
up vote 0 down vote accepted

I have got the solution. Here it is:

SETLOCAL EnableDelayedExpansion
set tes=0
set name=
set path=

for /r %%h in (*.*) do (
IF !tes! LSS %%~zh (
SET tes= %%~zh
SET name= %%~nh
SET path= %%~ph

echo name = !name! >> Biggest.txt
echo size = !tes! >> Biggest.txt
echo path = !path! >> Biggest.txt
share|improve this answer

Try this

dir /b /o-s>{temp}
set /P biggest=<{temp}
del {temp}
ren "%biggest%" the_biggest_file_here

click here for more details

share|improve this answer
Please consider editing your answer to be more appropriate to the question, instead of copying the source directly. The URL you provided talks about renaming the largest file in a directory. – user3463 Jul 31 '12 at 8:24
This gives the biggest file only in the current folder. I need to get the biggest file if it is there in the subfolder of the current folder – Sachin Jul 31 '12 at 11:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.