GNU Emacs Manual. Node: Dired Deletion

PREVDired Commands UPDired NEXTFlagging Many Files

26.3: Deleting Files with Dired

The primary use of Dired is to flag files for deletion and then delete the files previously flagged.

d

Flag this file for deletion.

u Remove deletion flag on this line.
DEL Move point to previous line and remove the deletion flag on that line.
x Delete the files that are flagged for deletion.

You can flag a file for deletion by moving to the line describing the file and typing d (dired-flag-file-deletion). The deletion flag is visible as a `D' at the beginning of the line. This command moves point to the next line, so that repeated d commands flag successive files. A numeric argument serves as a repeat count.

The files are flagged for deletion rather than deleted immediately to reduce the danger of deleting a file accidentally. Until you direct Dired to expunge the flagged files, you can remove deletion flags using the commands u and DEL. u (dired-unmark) works just like d, but removes flags rather than making flags. DEL (dired-unmark-backward) moves upward, removing flags; it is like u with argument ­1.

To delete the flagged files, type x (dired-expunge). This command first displays a list of all the file names flagged for deletion, and requests confirmation with yes. If you confirm, Dired deletes the flagged files, then deletes their lines from the text of the Dired buffer. The shortened Dired buffer remains selected.

If you answer no or quit with C-g when asked to confirm, you return immediately to Dired, with the deletion flags still present in the buffer, and no files actually deleted.

PREVDired Commands UPDired NEXTFlagging Many Files