help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy way to rename files sequentially?


From: Peter Dyballa
Subject: Re: Easy way to rename files sequentially?
Date: Sun, 25 Nov 2007 22:51:10 +0100


Am 25.11.2007 um 20:39 schrieb cothrige:

Is there some relatively easy way to add such a numerical prefix to a list of files?


Does this example from the info pages, Regexp Replacement, help?

    For example, to add consecutively numbered strings like `ABC00042'
    to columns 73 to 80 (unless they are already occupied), you can use

         M-x replace-regexp <RET> ^.\{0,72\}$ <RET>
         \,(format "%-72sABC%05d" \& \#) <RET>

Maybe in your case this works:

        M-x replace-regexp RET ^.*$ RET \,(format "%03d%s" \# \&) RET

i.e. use the complete original file name (\&) and prepend it by a zeroes padded three digit number (\# = number of already completed replacements, i.e. starting with 0). The format specification can of course contain additional text. But: dired does not understand \, nor \# in its regular expressions – or I am missing something!


You could create a shell script instead with code constructed with replace-regexp ...

--
Greetings

  Pete

Who the fsck is "General Failure," and why is he reading my disk?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]