Emacs: Rename Files Interactively

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

This pages shows you how to rename multiple files in emacs.

Summary

Go to the dir first, by calling dired. 〔➤ Emacs: File Management (dired tutorial)

When in dired, call dired-toggle-read-only.

Then, just edit the file names. When done, type

Following are details.

Rename by Editing File Names

KeyCommand NamePurpose
Ctrl+x Ctrl+q】 (emacs 23.1) dired-toggle-read-only or wdired-change-to-wdired-modeStart rename by editing
Ctrl+c Ctrl+cwdired-finish-editCommit changes
Ctrl+c Escwdired-abort-changesAbort changes

While in wdired, you can use find/replace. For example, call query-replace or call query-replace-regexp. 〔➤ Emacs: Find & Replace Tutorial〕 〔➤ Emacs: Text Pattern Matching (regex) tutorial

Warning: Emacs 22 Bug: Renaming to Existing File Name

There is a bug in emacs 22. (bug#394) If you rename 2 files by exchanging their names, one of the file will get deleted. This is fixed in emacs 23.

Like it? Buy Xah Emacs Tutorial.
blog comments powered by Disqus