Batch search each folder in a directory by file extention and just keep the biggest sized file of that extention and all other file types

  batch-file, cmd, windows

I have tried it this way to place a list in each folder using this code

@For /D %%I In ("c:Temp*")Do @(For %%J In ("%%I*.rts")Do @Echo %%~nxJ)>"%%I%%~nxI.txt"

worked fine but i couldn’t get it to list from largest to smallest in order to remove the first one and delete the rest.
so can it be fixed or is there an easier way.

Source: Windows Questions