Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 have dired and dired+ setup for viewing directory listings and use it as my file-manager for moving / copying files. Currently dired lists '0' as the size for all the subdirectories in any directory.

I would like to have dired calculate and display folder sizes. I would like this to be bound to a keystroke/mouse-click since I don't want dired to do this on every folder in every buffer.

As of now, I have "open in explorer" (w32-shell-execute in windows and gnome-open in gnome) bound to "O" from which I use Alt+Enter to calculate the subdirectory size.

share|improve this question
up vote 2 down vote accepted

This Emacs wiki page suggests using the following snippet to calculate the size of selected files and directories:

 (defun dired-get-size ()
  (interactive)
  (let ((files (dired-get-marked-files)))
    (with-temp-buffer
      (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
      (message "Size of all marked files: %s"
               (progn 
                 (re-search-backward "\\(^[0-9.,]+[A-Za-z]+\\).*total$")
                  (match-string 1))))))

 (define-key dired-mode-map (kbd "?") 'dired-get-size)

If I understand you correctly, you'd like to update value the Dired buffer directly. I'm not familiar enough with Dired's internals, but I guess it's shouldn't that hard.

share|improve this answer
    
I am ok if updating the dired buffer is not possible. I read also in the emacs wiki (emacswiki.org/emacs/Sunrise_Commander - jump to very end of page) that it is difficult to do so. However, I'd like a solution that would work in Linux as well as Windows. In fact, I primarily dired in Windows to escape from explorer. Is there 'du' for windows ? – koushik Aug 16 '12 at 18:48
    
I found out that I can get 'du' working in windows (cygwin or git - that works for me). Thanks for the solution ! It'd be nice if I can somehow get this info to persist in the dired buffer... – koushik Aug 16 '12 at 19:02

You must log in to answer this question.

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