11

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.

1
  • you can view the folders and subfolders through following command tree (drive letter :) e.g tree c: Jul 31, 2012 at 7:40

3 Answers 3

20

PowerShell can do this very easily:

Get-ChildItem -Path "C:\SomeParentDirectory" -Recurse | Sort-Object -Descending Length
1
  • 8
    Use the following command to get first 10 biggest files: Get-ChildItem -Path "c:\folder" -Recurse | Sort-Object -Descending Length | select-object -first 10 Jun 7, 2018 at 17:46
2

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
1
  • This does not work, at least for me. The problem is that in the If-condition, !tes! is never updated and stays the initial 0. Thus, the last processed file is being returned as the result.
    – Orsinus
    May 3, 2019 at 7:02
-1

Try this

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

click here for more details

2
  • 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, 2012 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, 2012 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .