This pages shows you how to rename multiple files in emacs. You can rename multiple files by find/replace, or by regex, in batch style or case-by-case.
go to the dir first, by calling
〔☛ Emacs: File Management (dired tutorial)〕
When in dired, call
wdired-change-to-wdired-mode. Then, just edit the file names. When done, type【Ctrl+c Ctrl+c】 to commit the changes. 【Ctrl+c Ctrl+k】 to abort the rename.
While in wdired mode, you can edit the file names by find/replace: call
query-replace or call
〔☛ emacs's Find/Replace commands〕
The rest of this page gives you some detail and alternative methods.
|【Ctrl+x Ctrl+q】 (emacs 23.1)||Start rename by editing|
|【Ctrl+c Ctrl+c】||Commit changes|
|【Ctrl+c Esc】||Abort changes|
This feature is also listed under the menu 〖Immediate ▸ Edit File Names〗. This menu is available only when you are in dired.
While in wdired, you can edit the list of file names by emacs's find/replace commands. For example, call
query-replace 【Alt+%】 or call
query-replace-regexp 【Ctrl+Alt+%】. 〔☛ Emacs: Find/Replace Tutorial〕
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, but i would be still careful if you rename many files that have existing names.
When renaming files to existing names, best to rename them to something else (such as adding a “x” in front), commit, and rename again.
A older method to rename files in batch is by the command
dired-do-rename-regexp 【% R】.
dired-do-rename-regexp is not as convenient as wdired.
Note: emacs's regex is not based on Perl's regex engine. For a summary and common patterns, see: Emacs Regex.