Sunday, April 13, 2008

Renaming a Pack-o-Files

A friend asked me a question that got me thinking that emacs must provide an easy way to rename a bunch of files in a directory from one thing to another. E.g., suppose I want to rename every file ending in .doc to a .tex extension. Point emacs at the directory, and type %m This fires off dired-mark-files-regexp, which selects files matching a regular expression. For the regular expression, try .doc$ Hit enter after each command. The '$' indicates that the pattern must occur at the end of a line. Now you can rename the marked files: %r This invokes dired-do-rename-regexp, which, for every marked file, asks what pattern to replace: doc$ It then asks what to change matching substrings to: tex ¡Voila! Much of the above is condensed from

No comments: