The Discovery

I used Emacs for years without knowing about this. In dired (the built-in file manager), type C-x C-q and the buffer becomes writeable. The modeline changes to "Editable" โ€” you're now in wdired-mode (Writeable Dired).

This means you can rename files the same way you edit text. Everything works: query-replace, keyboard macros, rectangle operations, multiple cursors โ€” whatever you'd normally use to transform text.

The Workflow

  1. Open a directory with C-x d (dired)
  2. Press C-x C-q to enter wdired-mode
  3. Edit filenames like normal text
  4. Press C-c C-c to commit changes to disk
  5. Or C-c C-k to discard and revert

The point: there's nothing new to learn. You already know how to edit text in Emacs. Now you're editing filenames.

What You Can Edit

By default, wdired only lets you edit filenames. Two settings extend it to:

  • File permissions โ€” chmod by editing the permission string directly
  • Symlink targets โ€” change where symbolic links point
;; In your init.el โ€” enable editing permissions and symlinks
(setq wdired-allow-to-change-permissions t)
(setq wdired-allow-to-redirect-links t)

Practical Example

Say you have 50 photos named IMG_20230815_*.jpg and want to rename them to vacation-*.jpg. In wdired: M-% (query-replace), replace IMG_20230815_ with vacation-, confirm with ! to replace all, then C-c C-c.

Try doing that in a graphical file manager.

Further Reading

Mickey Petersen's deep dive on wdired covers advanced usage including permission editing and integration with other dired features.