This page gives you some advanced tips on using emacs's dired for file manegement. If you don't know the basics of dired, see: emacs dired basics.
How to delete or copy a directory?
When you press D in dired, Emacs by default will not try to delete a non-empty dir. To set it to do so, put the following in your emacs init file:
;; allow dired to be able to delete or copy a whole dir. ;; “always” means no asking. “top” means ask once. Any other symbol means ask each and every time for a dir and subdir. (setq dired-recursive-copies (quote always)) (setq dired-recursive-deletes (quote top))
How to copy from one dired dir to the next dired dir shown in a split window?
Put the following in your emacs init file:
(setq dired-dwim-target t)
Now, go to dired, then call split-window-vertically, then go to another dired dir. Now, when you press C to copy, the other dir in the split pane will be default destination. Same for R (rename; move).
In a file, how to go to its directory and place cursor on the file name?
Use the command dired-jump 【Ctrl+x Ctrl+j】.
How to make dired use the same buffer for viewing directory, instead of spawning many?
In dired, you can press a instead of Enter ↵ to open the dir. This way, the previous dir will be automatically closed.
If you want Enter ↵ and ^ (parent dir) to use the same buffer, put the following in your emacs init file:
(add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map (kbd "<return>") 'dired-find-alternate-file) ; was dired-advertised-find-file (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) ; was dired-up-directory ))
How to hide some files?
Call dired-do-kill-lines 【k】 to hide marked files.
how to open a (image, pdf, doc) file in external apps?
How to rename multiple files?
For many extra features, you can install the “Dired+” mode. See: Using Emacs's “Dired+” Mode.