Emacs dired mode is an easy to use text-based file manager. By default, files are displayed in alphabetical order. Is there a way to sort the files by file size descending order?
Asked
Active
Viewed 6,932 times
16
-
2It is explained in this wiki: http://wikemacs.org/wiki/Dired#Sort_files and you have more options here: http://www.emacswiki.org/emacs/DiredSorting – Ehvince Dec 09 '14 at 14:24
-
@Ehvince Thank you. Wiki is a good place to learn. – Nick Dec 09 '14 at 14:27
2 Answers
24
You may customize the sort order by providing an argument to the dired-sort-toggle-or-edit
which is bound to the s keystroke.
So to answer your question, just type Control+u s and pass the -lS
switches.
You may pass -lhS
for human readable results.

Tassos
- 3,158
- 24
- 29
-
The option `l` means "long" and instructs the command to display files in a detailed format, including information such as permissions, owner, group, size, and modification date. The option `h` means "human-readable" and instructs the command to display file sizes in a more easily understandable format for humans, such as "1K" for 1 kilobyte or "1G" for 1 gigabyte. The option `S` means "size" and instructs the command to sort files by file size, placing the largest files at the top of the list. – Raoul HATTERER Feb 27 '23 at 23:52
9
You might want to use the extension dired-quick-sort. After setting it up, push "S" to display a sorting menu that offers many different ways to sort, including file size.
Disclaimer: I am the author of the extension.

xuhdev
- 8,018
- 2
- 41
- 69