xemacs redoubt

There are so many little and no-so-little programs out there for Mac that enable one to, say, validate a DTD, perform XSL transforms, or even batch rename some files. For some reason, I often find myself trying them out (the latest candidates were Editix, Oxygen, Renamer4Mac, etc.). At the end of the day, I always find myself back in XEmacs, doing the job faster and with less fuss. On the other hand, (X)Emacs tends to be fairly opaque, and it’s easy to forget stuff, so:

Since I always forget how to do a batch rename, here’s how: Select the files you want to rename by marking them in dired (‘m’ or use a regexp), then using the Regexp menu, select Rename… (or type % R). Then in the minibuffer, type the ‘from’ regexp (^.*$ selects the entire filename), hit return, and then the ‘to’ regexp. For example, % R ^.*$ <ret> x-& </ret><ret>' prepends anx-‘ to the filenames.

You can also use a grouping construct in a regexp to remember part of the original expression. For example, by surrounding part of the name in (…), we can refer to it later with a n, where the n is the occurrence of the match. For example, ^x(.)$ 1 would remove the initial x, and in another slightly more complicated example, ^xx(.)xx.(.*)$ 1.2 would turn xxfooxx.bar into foo.bar… Cool, eh?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.