emacs - dired

Look at dired without leaving the current buffer

C-x d

Dired tips

(Alphabetical order)

Ctrl x Ctrl f Visiting (opening) files. (This puts us in Emac’s dired mode - directory editor). To create a new file, just start typing the name of the file that you want to create.
g Refresh the listing in dired mode
m mark a file in dired mode
u un-mark a file in dired mode
U un-mark all files
w When you are in dired mode, if you put the point on a file and press w, the name of the file will be copied into the kill ring. Makes it easier if you are trying to rename files.
Ctrl x Ctrl q Turn dired into editing mode. You can then edit the file names by hand or use M-% to replace foo with bar in the dired buffer. This will change the file names. Use C-c C-c so apply the changes, or C-c ESC to cancel
d Flag this file for deletion (dired-flag-file-deletion).
C copy a file
R rename/move a file
D delete a file
u Remove the deletion flag (dired-unmark).
x Delete files flagged for deletion (dired-do-flagged-delete).

Supposing you wanted to delete a bunch of files, but wanted to see them first to visually check you are deleting the right ones, you might do the following:

  1. mark the files manually, or using a regular expression
  2. * t invert the selection
  3. k hide the selected files so now you see the ones you originally selected for deletion so you can check you got the right ones
  4. * s to select those visible files
  5. D to delete them

emacs - renaming files using dired

How to move a file using dired?

using wdired

  1. Exit evil-mode if you are using it
  2. Alt-x dired-toggle-read-only
  3. Make the changes to file names using regular emacs operations, rectangles, etc.
  4. Alt-x wdired-finish-edit

Using regular dired

  1. Using w, copy the name of the file.
  2. Hit R to rename the file
  3. Change the path
    1. Use help from the mini-buffer to navigate to the exact path where you want to move the file.
  4. In the directory where you want to place the file, paste the file name using Ctrl y
  5. The file will be moved there.

How to duplicate a file in dired?

https://www.gnu.org/software/emacs/manual/html_node/emacs/Operating-on-Files.html

  1. If you want to use the exact file name or use the initial file name with minimal changes, use w first to grab the name of the file.
  2. Hit C
  3. Specify the path and filename of the duplicate file to be created.
    1. Use help from the mini-buffer to navigate to the exact path where the copy is supposed to be placed.

TODO

  1. https://www.emacswiki.org/emacs/DiredPower

Links to this note