Copy and paste files with dired-ranger

I’ve written before about managing files in Emacs using dired. The package dired-ranger provides a useful extension to dired, allowing you to copy and paste files much like you can do in traditional GUI file explorers.

First, install dired-ranger with something like the following

(use-package dired-ranger
  :ensure t
  :bind (:map dired-mode-map
              ("W" . dired-ranger-copy)
              ("X" . dired-ranger-move)
              ("Y" . dired-ranger-paste)))

This also sets up some useful keybindings. Now in a dired buffer, you can mark multiple files and then hit W to copy them (really they are added to a copy ring). You could then optionally go to another directory and mark more files and hit C-u W to add those to the same entry in the copy ring as the previous files. This builds up a virtual collection of files that you can then copy or move. Now go to the target directory and hit X to move the copied files to that directory (i.e. they are deleted from their original location) or Y to copy the files to the target directory (the originals remain where they were).

You can achieve similar results using dired-dwim-target or Sunrise Commander, but this method clicks with me and is the one that I use.