all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Easy way to rename files sequentially?
@ 2007-11-25 19:39 cothrige
  2007-11-25 20:35 ` Sven Bretfeld
                   ` (6 more replies)
  0 siblings, 7 replies; 44+ messages in thread
From: cothrige @ 2007-11-25 19:39 UTC (permalink / raw)
  To: help-gnu-emacs


I sometimes have a list of files which I would like to rename both in a
group and in sequence.  In the past, for very long lists of files with a
number in the name, e.g. "some random audio file ep 01 of 200.mp3", I
would use thunar as it will very easily and automatically add a
sequential number to the front of the names, resulting in 01-xxx.mp3 and
so on.  Of course, there are many reasons I would rather not have to use
thunar, and would prefer to be able to do it from within emacs.  I have
managed to do this a few times using wdired and a keyboard macro, and
this really isn't too bad.  But it seems there must be a better way to
rename a list of files and sequentially number them.  Is there some
relatively easy way to add such a numerical prefix to a list of files?

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 19:39 Easy way to rename files sequentially? cothrige
@ 2007-11-25 20:35 ` Sven Bretfeld
  2007-11-25 21:12 ` Eli Zaretskii
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 44+ messages in thread
From: Sven Bretfeld @ 2007-11-25 20:35 UTC (permalink / raw)
  To: cothrige; +Cc: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 1089 bytes --]

cothrige <cothrige@yahoo.com> writes:

> I sometimes have a list of files which I would like to rename both in a
> group and in sequence.  In the past, for very long lists of files with a
> number in the name, e.g. "some random audio file ep 01 of 200.mp3", I
> would use thunar as it will very easily and automatically add a
> sequential number to the front of the names, resulting in 01-xxx.mp3 and
> so on.  Of course, there are many reasons I would rather not have to use
> thunar, and would prefer to be able to do it from within emacs.  I have
> managed to do this a few times using wdired and a keyboard macro, and
> this really isn't too bad.  But it seems there must be a better way to
> rename a list of files and sequentially number them.  Is there some
> relatively easy way to add such a numerical prefix to a list of files?

I don't know a good Emacs-solution (which no doubt exists). But if you
are under GNU, you should consider the program mmv which is most easy
to handle and does what you want. It should be contained in the repos
of all major distris.

Greetings

Sven

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 19:39 Easy way to rename files sequentially? cothrige
  2007-11-25 20:35 ` Sven Bretfeld
@ 2007-11-25 21:12 ` Eli Zaretskii
  2007-11-25 21:46   ` reader
  2007-11-25 21:19 ` Xah Lee
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Eli Zaretskii @ 2007-11-25 21:12 UTC (permalink / raw)
  To: help-gnu-emacs

> From: cothrige <cothrige@yahoo.com>
> Date: Sun, 25 Nov 2007 13:39:45 -0600
> 
> 
> I sometimes have a list of files which I would like to rename both in a
> group and in sequence.  In the past, for very long lists of files with a
> number in the name, e.g. "some random audio file ep 01 of 200.mp3", I
> would use thunar as it will very easily and automatically add a
> sequential number to the front of the names, resulting in 01-xxx.mp3 and
> so on.  Of course, there are many reasons I would rather not have to use
> thunar, and would prefer to be able to do it from within emacs.  I have
> managed to do this a few times using wdired and a keyboard macro, and
> this really isn't too bad.  But it seems there must be a better way to
> rename a list of files and sequentially number them.  Is there some
> relatively easy way to add such a numerical prefix to a list of files?

Try the "% R" command in Dired.  It computes the new name by
regular-expression substitution from the old name.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 19:39 Easy way to rename files sequentially? cothrige
  2007-11-25 20:35 ` Sven Bretfeld
  2007-11-25 21:12 ` Eli Zaretskii
@ 2007-11-25 21:19 ` Xah Lee
  2007-11-25 22:40   ` reader
  2007-11-25 21:51 ` Peter Dyballa
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Xah Lee @ 2007-11-25 21:19 UTC (permalink / raw)
  To: help-gnu-emacs

See:

* Rename Files by a Text Pattern
http://xahlee.org/emacs/rename_file_pattern.html

summary:
Alt+x dired
Alt+x dired-do-rename-regexp

if this does not satisfy your creating sequencial numbers for file
names... write back more pls and i'll try to help. (or the group)

  Xah
  xah@xahlee.org
\xAD\xF4 http://xahlee.org/

On Nov 25, 11:39 am, cothrige <cothr...@yahoo.com> wrote:
> I sometimes have a list of files which I would like to rename both in a
> group and in sequence.  In the past, for very long lists of files with a
> number in the name, e.g. "some random audio file ep 01 of 200.mp3", I
> would use thunar as it will very easily and automatically add a
> sequential number to the front of the names, resulting in 01-xxx.mp3 and
> so on.  Of course, there are many reasons I would rather not have to use
> thunar, and would prefer to be able to do it from within emacs.  I have
> managed to do this a few times using wdired and a keyboard macro, and
> this really isn't too bad.  But it seems there must be a better way to
> rename a list of files and sequentially number them.  Is there some
> relatively easy way to add such a numerical prefix to a list of files?
>
> Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 21:12 ` Eli Zaretskii
@ 2007-11-25 21:46   ` reader
  2007-11-26  3:39     ` Eli Zaretskii
  0 siblings, 1 reply; 44+ messages in thread
From: reader @ 2007-11-25 21:46 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> Try the "% R" command in Dired.  It computes the new name by
> regular-expression substitution from the old name.

Eli, probably obvious to you but how does that method allow sequential
numbering?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 19:39 Easy way to rename files sequentially? cothrige
                   ` (2 preceding siblings ...)
  2007-11-25 21:19 ` Xah Lee
@ 2007-11-25 21:51 ` Peter Dyballa
  2007-11-25 23:34   ` reader
  2007-11-25 23:11 ` Bastien
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Peter Dyballa @ 2007-11-25 21:51 UTC (permalink / raw)
  To: cothrige; +Cc: help-gnu-emacs


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?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 21:19 ` Xah Lee
@ 2007-11-25 22:40   ` reader
  2007-11-25 23:16     ` Peter Dyballa
  0 siblings, 1 reply; 44+ messages in thread
From: reader @ 2007-11-25 22:40 UTC (permalink / raw)
  To: help-gnu-emacs

Xah Lee <xah@xahlee.org> writes:

> See:
>
> * Rename Files by a Text Pattern
> http://xahlee.org/emacs/rename_file_pattern.html
>
> summary:
> Alt+x dired
> Alt+x dired-do-rename-regexp
>
> if this does not satisfy your creating sequencial numbers for file
> names... write back more pls and i'll try to help. (or the group)

I'm probably blind but I see nothing there about sequential numbering.

Then Peters post speaks of adding strings to `columns'

I guess what is throwning me is the use of format strings that are not
explained to generate the numbers.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 19:39 Easy way to rename files sequentially? cothrige
                   ` (3 preceding siblings ...)
  2007-11-25 21:51 ` Peter Dyballa
@ 2007-11-25 23:11 ` Bastien
       [not found] ` <mailman.4087.1196027477.18990.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.4081.1196022933.18990.help-gnu-emacs@gnu.org>
  6 siblings, 0 replies; 44+ messages in thread
From: Bastien @ 2007-11-25 23:11 UTC (permalink / raw)
  To: help-gnu-emacs

cothrige <cothrige@yahoo.com> writes:

> I sometimes have a list of files which I would like to rename both in
> a group and in sequence.  In the past, for very long lists of files
> with a number in the name, e.g. "some random audio file ep 01 of
> 200.mp3", I would use thunar as it will very easily and automatically
> add a sequential number to the front of the names, resulting in
> 01-xxx.mp3 and so on.  Of course, there are many reasons I would
> rather not have to use thunar, and would prefer to be able to do it
> from within emacs.  I have managed to do this a few times using wdired
> and a keyboard macro, and this really isn't too bad.

Yes, this isn't that bad at all (considered the number of times I need
to renumber files sequentially -- but you might have other needs.)

Here is how I do it (for those interested):

0. (wdired-change-to-wdired-mode) [which I bind to C-c C-c]
1. <F3> (kmacro-start-macro-or-insert-counter)
2. Put the point where to add the number in the file
3. <F3> again to insert the counter value
4. Put the point where to add the number in the next file
5. <F4> to save the macro

C-e e e e e ... does the job for me.

-- 
Bastien

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 22:40   ` reader
@ 2007-11-25 23:16     ` Peter Dyballa
  2007-11-25 23:50       ` reader
  0 siblings, 1 reply; 44+ messages in thread
From: Peter Dyballa @ 2007-11-25 23:16 UTC (permalink / raw)
  To: reader; +Cc: help-gnu-emacs


Am 25.11.2007 um 23:40 schrieb reader:

> I guess what is throwning me is the use of format strings that are not
> explained to generate the numbers.

What more information do you need? C-h f format RET? Is it this?

--
Greetings

   Pete

If my theory of relativity is proven successful, Germany will claim  
me as a German, and France will declare that I am a citizen of the  
world. Should my theory prove untrue, France will say that I am a  
German, and Germany will declare that I am a Jew.
                                                 -- Albert Einstein,  
1929

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 21:51 ` Peter Dyballa
@ 2007-11-25 23:34   ` reader
  0 siblings, 0 replies; 44+ messages in thread
From: reader @ 2007-11-25 23:34 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> 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!

How can this possibly do what the OP has asked about?  It fails in my
case but you seem to have known that \. or \# wouldn't work in dired.

  dired-string-replace-match: Invalid use of `\' in replacement text

So I guess I'm missing what the utility of your post was meant to be.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 23:16     ` Peter Dyballa
@ 2007-11-25 23:50       ` reader
  2007-11-26  9:20         ` Peter Dyballa
  0 siblings, 1 reply; 44+ messages in thread
From: reader @ 2007-11-25 23:50 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> Am 25.11.2007 um 23:40 schrieb reader:
>
>> I guess what is throwning me is the use of format strings that are not
>> explained to generate the numbers.
>
> What more information do you need? C-h f format RET? Is it this?
>

I guess that might be helpful except I still am so blind I'm not
seeing how numbers are incremented.  I've posted the content with line
numbers. Can you show me the relevant lines?

1  format is a built-in function in `C source code'.
2  (format STRING &rest OBJECTS)

3  Format a string out of a format-string and arguments.
4  The first argument is a format control string.
5  The other arguments are substituted into it to make the result, a string.
6  It may contain %-sequences meaning to substitute the next argument.
7  %s means print a string argument.  Actually, prints any object, with `princ'.
8  %d means print as number in decimal (%o octal, %x hex).
9  %X is like %x, but uses upper case.
10 %e means print a number in exponential notation.
11 %f means print a number in decimal-point notation.
12 %g means print a number in exponential notation
    or decimal-point notation, whichever uses fewer characters.
13 %c means print a number as a single character.
14 %S means print any object as an s-expression (using `prin1').

15  The argument used for %d, %o, %x, %e, %f, %g or %c must be a number.
16   Use %% to put a single % into the output.

17 The basic structure of a %-sequence is
18   % <flags> <width> <precision> character
19 where flags is [-+ #0]+, width is [0-9]+, and precision is .[0-9]+

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 21:46   ` reader
@ 2007-11-26  3:39     ` Eli Zaretskii
  2007-11-26  7:33       ` reader
       [not found]       ` <mailman.4107.1196062436.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2007-11-26  3:39 UTC (permalink / raw)
  To: help-gnu-emacs

> From: reader@newsguy.com
> Date: Sun, 25 Nov 2007 15:46:38 -0600
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Try the "% R" command in Dired.  It computes the new name by
> > regular-expression substitution from the old name.
> 
> Eli, probably obvious to you but how does that method allow sequential
> numbering?

I must admit don't really understand what did you mean by ``sequential
numbering''.  How about an example?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26  3:39     ` Eli Zaretskii
@ 2007-11-26  7:33       ` reader
  2007-11-26 12:49         ` David Hansen
                           ` (2 more replies)
       [not found]       ` <mailman.4107.1196062436.18990.help-gnu-emacs@gnu.org>
  1 sibling, 3 replies; 44+ messages in thread
From: reader @ 2007-11-26  7:33 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: reader@newsguy.com
>> Date: Sun, 25 Nov 2007 15:46:38 -0600
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Try the "% R" command in Dired.  It computes the new name by
>> > regular-expression substitution from the old name.
>> 
>> Eli, probably obvious to you but how does that method allow sequential
>> numbering?
>
> I must admit don't really understand what did you mean by ``sequential
> numbering''.  How about an example?

I took the meaning from the OP:

   "I sometimes have a list of files which I would like to rename both
    in a group and in sequence."

So something like:

img-0987.jpg
img-9027.jpg
img-1237.jpg
img-0007.jpg

Might become:

000-img-0987.jpg
001-img-9027.jpg
002-img-1237.jpg
003-img-0007.jpg

Or if keeping the original for reference is not needed then possibly:

img-000.jpg
img-001.jpg
img-002.jpg
img-003.jpg

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-25 23:50       ` reader
@ 2007-11-26  9:20         ` Peter Dyballa
  2007-11-26 18:11           ` reader
  0 siblings, 1 reply; 44+ messages in thread
From: Peter Dyballa @ 2007-11-26  9:20 UTC (permalink / raw)
  To: reader; +Cc: help-gnu-emacs


Am 26.11.2007 um 00:50 schrieb reader:

> I guess that might be helpful except I still am so blind I'm not
> seeing how numbers are incremented.


Automagically. The format command does not increment. How could it  
know that it's in kind of a loop? So replace-regexp tracks what it's  
doing.

--
Greetings

   Pete

Rain is saved up in cloud banks.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26  7:33       ` reader
@ 2007-11-26 12:49         ` David Hansen
  2007-11-26 17:56           ` reader
  2007-11-26 20:03         ` Eli Zaretskii
       [not found]         ` <mailman.4117.1196081659.18990.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 44+ messages in thread
From: David Hansen @ 2007-11-26 12:49 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 26 Nov 2007 01:33:36 -0600 reader@newsguy.com wrote:

> So something like:
>
> img-0987.jpg
> img-9027.jpg
> img-1237.jpg
> img-0007.jpg
>
> Might become:
>
> 000-img-0987.jpg
> 001-img-9027.jpg
> 002-img-1237.jpg
> 003-img-0007.jpg

M-x wdired-change-to-wdired-mode RET
C-M-% img RET \,(format "%03d" \#)-img RET
!
C-c C-c

> Or if keeping the original for reference is not needed then possibly:
>
> img-000.jpg
> img-001.jpg
> img-002.jpg
> img-003.jpg

M-x wdired-change-to-wdired-mode RET
C-M-% img-[0-9]+ RET img-\,(format "%03d" \#) RET
!
C-c C-c

David

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 12:49         ` David Hansen
@ 2007-11-26 17:56           ` reader
  2007-11-26 18:26             ` David Hansen
  2007-11-26 20:08             ` Thierry Volpiatto
  0 siblings, 2 replies; 44+ messages in thread
From: reader @ 2007-11-26 17:56 UTC (permalink / raw)
  To: help-gnu-emacs

David Hansen <david.hansen@gmx.net> writes:

> On Mon, 26 Nov 2007 01:33:36 -0600 reader@newsguy.com wrote:
>
>> So something like:
>>
>> img-0987.jpg
>> img-9027.jpg
>> img-1237.jpg
>> img-0007.jpg
>>
>> Might become:
>>
>> 000-img-0987.jpg
>> 001-img-9027.jpg
>> 002-img-1237.jpg
>> 003-img-0007.jpg
>
> M-x wdired-change-to-wdired-mode RET
> C-M-% img RET \,(format "%03d" \#)-img RET
> !
> C-c C-c
>
>> Or if keeping the original for reference is not needed then possibly:
>>
>> img-000.jpg
>> img-001.jpg
>> img-002.jpg
>> img-003.jpg
>
> M-x wdired-change-to-wdired-mode RET
> C-M-% img-[0-9]+ RET img-\,(format "%03d" \#) RET
> !
> C-c C-c

Thanks for showing the method... I was hoping to do this from plain
dired mode and that is what my input has been about.  I didn't want to
have to switch back and forth from wdired to have access to all the
normal dired tools.

Is it possible to do that from normal dired mode?  I know some of
methods you used will not work in dired but is there anyway at all to
accomplish sequential numbering from dired?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26  9:20         ` Peter Dyballa
@ 2007-11-26 18:11           ` reader
  2007-11-26 22:23             ` Peter Dyballa
  0 siblings, 1 reply; 44+ messages in thread
From: reader @ 2007-11-26 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> Am 26.11.2007 um 00:50 schrieb reader:
>
>> I guess that might be helpful except I still am so blind I'm not
>> seeing how numbers are incremented.
>
>
> Automagically. The format command does not increment. How could it
> know that it's in kind of a loop? So replace-regexp tracks what it's
> doing.

First, Peter thank you for taking time to respond.

But Peter, that is what my questions are about... how to accomplish
sequential numbering.  So what is there at your citation that informs
me about that?

Although you have gone to some trouble to respond, I guess I'm having
a lot of trouble understanding your meaning in these posts...

My input in this thread started with a question directed at Eli about
the use of % R (from dired of course)

My questions are about dired mode.  Eli's input indicated one could do
something with % R from dired.  

What you've shown, at least in part does not apply to dired mode does
it?  At least some of the operators you keep referring to are not
available in dired, or so it appears at this end.

Since I've gotten pretty confused reading your replies maybe its time
to wait for Eli if he is of a mind to respond, or mabye you can tell
me how to do sequential numbering specifically from dired with a small
example.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 17:56           ` reader
@ 2007-11-26 18:26             ` David Hansen
  2007-11-26 20:40               ` Eli Zaretskii
       [not found]               ` <mailman.4145.1196109649.18990.help-gnu-emacs@gnu.org>
  2007-11-26 20:08             ` Thierry Volpiatto
  1 sibling, 2 replies; 44+ messages in thread
From: David Hansen @ 2007-11-26 18:26 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 26 Nov 2007 11:56:52 -0600 reader@newsguy.com wrote:

> David Hansen <david.hansen@gmx.net> writes:
>
>> [sequental renaming using wdired]
>
> Thanks for showing the method... I was hoping to do this from plain
> dired mode and that is what my input has been about.  I didn't want to
> have to switch back and forth from wdired to have access to all the
> normal dired tools.
>
> Is it possible to do that from normal dired mode?  I know some of
> methods you used will not work in dired but is there anyway at all to
> accomplish sequential numbering from dired?

\# isn't working in `dired-do-rename-regexp' so I suspect there is no
such method, but I may be wrong.  Anyway, if you bind
`wdired-change-to-wdired-mode' to some key it's only to key bindings
more...

David

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26  7:33       ` reader
  2007-11-26 12:49         ` David Hansen
@ 2007-11-26 20:03         ` Eli Zaretskii
  2007-11-27 19:31           ` reader
       [not found]           ` <mailman.4195.1196192427.18990.help-gnu-emacs@gnu.org>
       [not found]         ` <mailman.4117.1196081659.18990.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2007-11-26 20:03 UTC (permalink / raw)
  To: help-gnu-emacs

> From: reader@newsguy.com
> Date: Mon, 26 Nov 2007 01:33:36 -0600
> 
> So something like:
> 
> img-0987.jpg
> img-9027.jpg
> img-1237.jpg
> img-0007.jpg
> 
> Might become:
> 
> 000-img-0987.jpg
> 001-img-9027.jpg
> 002-img-1237.jpg
> 003-img-0007.jpg
> 
> Or if keeping the original for reference is not needed then possibly:
> 
> img-000.jpg
> img-001.jpg
> img-002.jpg
> img-003.jpg

You should be able to use the \, construct to invoke `format' or some
similar function and advance the counter.  See the example in

   (emacs) Regexp Replace

in the Emacs manual.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 17:56           ` reader
  2007-11-26 18:26             ` David Hansen
@ 2007-11-26 20:08             ` Thierry Volpiatto
  2007-11-27  7:07               ` Sebastian Tennant
  1 sibling, 1 reply; 44+ messages in thread
From: Thierry Volpiatto @ 2007-11-26 20:08 UTC (permalink / raw)
  To: help-gnu-emacs


Hi, i use a script python to serial rename,
called serialrename.py.(i can attach it next post if interested) 
i try to use it with this defun, renaming a dir ~/test_wdired
with some file like toto.txt etc... to file 01.txt etc..


(defun rename-all-with-number ()
  (interactive)
  (wdired-change-to-wdired-mode)
  (shell-command "~/bin/serialrename.py -d ~/test_wdired/ -e txt"))

Thats work fine but i don't know how to put ~/test_wdired/ in option;
I would like to do some thing like that:

(defun rename-all-with-number (dir)
  (interactive "sDir: ")
  (wdired-change-to-wdired-mode)
  (shell-command "~/bin/serialrename.py -d dir -e txt"))

In python i can do some thing like: 

".....%s" % ~/test_wdired

but in lisp i don't know how.
the best would be to write all in lisp but it's too hard for me now.

-- 
A + Thierry

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 18:26             ` David Hansen
@ 2007-11-26 20:40               ` Eli Zaretskii
       [not found]               ` <mailman.4145.1196109649.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 44+ messages in thread
From: Eli Zaretskii @ 2007-11-26 20:40 UTC (permalink / raw)
  To: help-gnu-emacs

> From: David Hansen <david.hansen@gmx.net>
> Date: Mon, 26 Nov 2007 18:26:02 +0000
> 
> \# isn't working in `dired-do-rename-regexp'

That sounds like a bug (or missing feature) to me:
dired-do-rename-regexp is supposed to be 100% compatible with
query-replace-regexp, as far as regexp replacement goes.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]               ` <mailman.4145.1196109649.18990.help-gnu-emacs@gnu.org>
@ 2007-11-26 21:00                 ` David Kastrup
  0 siblings, 0 replies; 44+ messages in thread
From: David Kastrup @ 2007-11-26 21:00 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: David Hansen <david.hansen@gmx.net>
>> Date: Mon, 26 Nov 2007 18:26:02 +0000
>> 
>> \# isn't working in `dired-do-rename-regexp'
>
> That sounds like a bug (or missing feature) to me:
> dired-do-rename-regexp is supposed to be 100% compatible with
> query-replace-regexp, as far as regexp replacement goes.

Missing feature.  query-replace-regexp offers this sort of replacement
only in interactive use (it implements it mostly by translating the
replacement string into a list which gets interpreted specially by
perform-replace).  I have taken a look at the respective code in
replace.el, and it is not really prepared for doing string replacements
right now.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 18:11           ` reader
@ 2007-11-26 22:23             ` Peter Dyballa
  2007-11-27 19:28               ` reader
  0 siblings, 1 reply; 44+ messages in thread
From: Peter Dyballa @ 2007-11-26 22:23 UTC (permalink / raw)
  To: reader; +Cc: help-gnu-emacs


Am 26.11.2007 um 19:11 schrieb reader:

> But Peter, that is what my questions are about... how to accomplish
> sequential numbering.  So what is there at your citation that informs
> me about that?

To cite myself: (\# = number of already completed replacements, i.e.  
starting with 0).

>
> My input in this thread started with a question directed at Eli about
> the use of % R (from dired of course)

That's the key binding in dired-mode which starts the renaming  
(moving) action/process.

>
> What you've shown, at least in part does not apply to dired mode does
> it?  At least some of the operators you keep referring to are not
> available in dired, or so it appears at this end.

I thought the new extension (since GNU Emacs 22) would work in dired- 
mode when I started to reply (and I did not see any other method than  
that described, so I started before making the test). Then I checked  
before I sent my reply and had to find that neither \, nor \# work.  
Wdired seems to be a working option that I did not check yet. And  
that I did not know of until now. At least I did not remember what  
I've once or twice read but never had to use yet ...


Besides I mentioned, as another option, to use a shell or whatever  
script when the simple approach with dired does not work. To produce  
that script the given code might be helpful to produce the target name.


Anyway, it's not that bad to look up a given reference. It can,  
sometimes (?), explain more than I can.

--
Greetings

   Pete

"Specifications are for the weak and timid!"

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 20:08             ` Thierry Volpiatto
@ 2007-11-27  7:07               ` Sebastian Tennant
  2007-11-27  7:18                 ` Thierry Volpiatto
  2007-11-27 15:14                 ` Thierry Volpiatto
  0 siblings, 2 replies; 44+ messages in thread
From: Sebastian Tennant @ 2007-11-27  7:07 UTC (permalink / raw)
  To: help-gnu-emacs

Quoth Thierry Volpiatto <thierry.volpiatto@gmail.com>:
> I would like to do some thing like that:
>
>   (shell-command "~/bin/serialrename.py -d dir -e txt"))

I believe what you want can be achieved like this:

 (shell-command (format "~/bin/serialrename.py -d %s -e txt" dir))

Sebastian

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27  7:07               ` Sebastian Tennant
@ 2007-11-27  7:18                 ` Thierry Volpiatto
  2007-11-27 15:14                 ` Thierry Volpiatto
  1 sibling, 0 replies; 44+ messages in thread
From: Thierry Volpiatto @ 2007-11-27  7:18 UTC (permalink / raw)
  To: Sebastian Tennant; +Cc: help-gnu-emacs

Sebastian Tennant <sebyte@smolny.plus.com> writes:

> Quoth Thierry Volpiatto <thierry.volpiatto@gmail.com>:
>> I would like to do some thing like that:
>>
>>   (shell-command "~/bin/serialrename.py -d dir -e txt"))
>
> I believe what you want can be achieved like this:
>
>  (shell-command (format "~/bin/serialrename.py -d %s -e txt" dir))
>
Yes that's it. (format)
Thank you.
-- 
A + Thierry

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27  7:07               ` Sebastian Tennant
  2007-11-27  7:18                 ` Thierry Volpiatto
@ 2007-11-27 15:14                 ` Thierry Volpiatto
  2007-11-27 15:20                   ` Sebastian Tennant
  1 sibling, 1 reply; 44+ messages in thread
From: Thierry Volpiatto @ 2007-11-27 15:14 UTC (permalink / raw)
  To: Sebastian Tennant; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

Sebastian Tennant <sebyte@smolny.plus.com> writes:

> Quoth Thierry Volpiatto <thierry.volpiatto@gmail.com>:
>> I would like to do some thing like that:
>>
>>   (shell-command "~/bin/serialrename.py -d dir -e txt"))
>
> I believe what you want can be achieved like this:
>
>  (shell-command (format "~/bin/serialrename.py -d %s -e txt" dir))
>
Thank you again, i did that, it work fine :)

(setq serial-rename-command "~/bin/serialrename.py")

(defun tv-serial-rename (dir ext name start)
  (interactive "sDir: \nsExt: \nsName: \nsStart: ")
  (find-file dir)
  (shell-command 
   (format "%s -d %s -e %s -n %s -s %s" 
	   serial-rename-command dir ext name start)))

Ci joint le script python:

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: script python --]
[-- Type: text/x-python, Size: 1778 bytes --]

#!/usr/bin/python
# -*- coding: utf-8 -*-
# 	$Id: serialrename.py,v 1.5 2007/11/27 15:05:06 thierry Exp $	


#commentary:
#Rename the content of a directory
#+with incremental numbers
#+ for a specific extension file

import os
from optparse import OptionParser
import sys

parser = OptionParser()

parser.add_option("-d",
                  "--dir",
                  dest="rep",
                  help ="Input directory(with / at the end please)")
parser.add_option("-n",
                  "--name",
                  dest="nom",
                  default="file",
                  help ="optional:file name")
parser.add_option("-s",
                  "--start-number",
                  dest="startn",
                  default=101,
                  help ="optional:initial incremental number")
parser.add_option("-e",
                  "--ext",
                  dest="extension",
                  help ="file type - ex: jpg(without dot)")

(options, args) = parser.parse_args()

rep = options.rep
nom = options.nom
startn = int(options.startn)
extension = options.extension

if len(sys.argv) < 3:
    parser.error("Serialrename take at list 2 arguments\n you must specify options -d and -e")
else:
    try:
        dir_photos = os.listdir(rep)
        for i in dir_photos:
            if extension in i:
                new = rep + nom + str(startn) + "." + extension
                if new not in dir_photos:
                    print new
                    os.rename(rep + i, new)
                    startn += 1
                else:
                    print new, "new"
                    os.rename(rep + i, new + "new")
                    startn += 1
    except (IOError, TypeError):
        raise "Check the path of your dir - Have you forget the / at the end ?"

[-- Attachment #3: Type: text/plain, Size: 17 bytes --]


-- 
A + Thierry

[-- Attachment #4: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27 15:14                 ` Thierry Volpiatto
@ 2007-11-27 15:20                   ` Sebastian Tennant
  0 siblings, 0 replies; 44+ messages in thread
From: Sebastian Tennant @ 2007-11-27 15:20 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: help-gnu-emacs

Quoth Thierry Volpiatto <thierry.volpiatto@gmail.com>:
> Sebastian Tennant <sebyte@smolny.plus.com> writes:
>
>> Quoth Thierry Volpiatto <thierry.volpiatto@gmail.com>:
>>> I would like to do some thing like that:
>>>
>>>   (shell-command "~/bin/serialrename.py -d dir -e txt"))
>>
>> I believe what you want can be achieved like this:
>>
>>  (shell-command (format "~/bin/serialrename.py -d %s -e txt" dir))
>>
> Thank you again, i did that, it work fine :)

Pleased to be able to help :-)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 22:23             ` Peter Dyballa
@ 2007-11-27 19:28               ` reader
  0 siblings, 0 replies; 44+ messages in thread
From: reader @ 2007-11-27 19:28 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> Anyway, it's not that bad to look up a given reference. It can,
> sometimes (?), explain more than I can.

No, and none of your input was taken as bad.  Thanks again

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-26 20:03         ` Eli Zaretskii
@ 2007-11-27 19:31           ` reader
       [not found]           ` <mailman.4195.1196192427.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 44+ messages in thread
From: reader @ 2007-11-27 19:31 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

> You should be able to use the \, construct to invoke `format' or some
> similar function and advance the counter.  See the example in

Thats not available in dired either is it?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]           ` <mailman.4195.1196192427.18990.help-gnu-emacs@gnu.org>
@ 2007-11-27 20:12             ` Joel J. Adamson
  2007-11-27 21:35               ` Thierry Volpiatto
  0 siblings, 1 reply; 44+ messages in thread
From: Joel J. Adamson @ 2007-11-27 20:12 UTC (permalink / raw)
  To: help-gnu-emacs

reader@newsguy.com writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> You should be able to use the \, construct to invoke `format' or some
>> similar function and advance the counter.  See the example in
>
> Thats not available in dired either is it?

M-x wdired-change-to-wdired-mode

and then you can edit filenames freely as you would edit a file,
i.e. you can use any of the search and replace functions.  To rename
files sequentially, as long as they are in the order you expect them to
be, you can use a regex with "\#" which represents the number of
substitutions.

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27 20:12             ` Joel J. Adamson
@ 2007-11-27 21:35               ` Thierry Volpiatto
  2007-11-27 22:00                 ` Joel J. Adamson
       [not found]                 ` <mailman.4203.1196200844.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 44+ messages in thread
From: Thierry Volpiatto @ 2007-11-27 21:35 UTC (permalink / raw)
  To: Joel J. Adamson; +Cc: help-gnu-emacs

jadamson@partners.org (Joel J. Adamson) writes:

> reader@newsguy.com writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>> You should be able to use the \, construct to invoke `format' or some
>>> similar function and advance the counter.  See the example in
>>
>> Thats not available in dired either is it?
>
> M-x wdired-change-to-wdired-mode
>
> and then you can edit filenames freely as you would edit a file,
> i.e. you can use any of the search and replace functions.  To rename
> files sequentially, as long as they are in the order you expect them to
> be, you can use a regex with "\#" which represents the number of
> substitutions.
>
> Joel

It work really well with "\#", thank you Joel.
After wdired-change-to-wdired-mode, i did :

C-M % RET
query-replace-regex: [a-z0-9]*.txt RET thierry\#.txt

with some files like:
riri.txt
titi2.txt
toto23.txt

So which one is the counter, "\" or "#" ?

-- 
A + Thierry

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27 21:35               ` Thierry Volpiatto
@ 2007-11-27 22:00                 ` Joel J. Adamson
       [not found]                 ` <mailman.4203.1196200844.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 44+ messages in thread
From: Joel J. Adamson @ 2007-11-27 22:00 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: help-gnu-emacs

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> jadamson@partners.org (Joel J. Adamson) writes:
>
>> reader@newsguy.com writes:
>>
>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>
>>>> You should be able to use the \, construct to invoke `format' or some
>>>> similar function and advance the counter.  See the example in
>>>
>>> Thats not available in dired either is it?
>>
>> M-x wdired-change-to-wdired-mode
>>
>> and then you can edit filenames freely as you would edit a file,
>> i.e. you can use any of the search and replace functions.  To rename
>> files sequentially, as long as they are in the order you expect them to
>> be, you can use a regex with "\#" which represents the number of
>> substitutions.
>>
>> Joel
>
> It work really well with "\#", thank you Joel.

[...]

You're welcome, I'm glad to help.

> So which one is the counter, "\" or "#" ?
>

`\' and `#' together are a symbol meaning a counter in a replacement
pattern.  `\,' is the construct that says "LISP IS COMING!"

In case I failed to mention, I often use `(string-to-int \1)' for
addition, e.g.

\,(+ \# (string-to-int \1))

to add number of replacements to the captured regex.

Joel
-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]                 ` <mailman.4203.1196200844.18990.help-gnu-emacs@gnu.org>
@ 2007-11-27 23:40                   ` Johan Bockgård
  2007-11-27 23:43                   ` David Kastrup
  1 sibling, 0 replies; 44+ messages in thread
From: Johan Bockgård @ 2007-11-27 23:40 UTC (permalink / raw)
  To: help-gnu-emacs

jadamson@partners.org (Joel J. Adamson) writes:

> I often use `(string-to-int \1)'

   "`\&' is a string denoting the whole match as a string, `\N' for a
    partial match, `\#&' and `\#N' for the whole or a partial match
    converted to a number with `string-to-number' [...]"

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]                 ` <mailman.4203.1196200844.18990.help-gnu-emacs@gnu.org>
  2007-11-27 23:40                   ` Johan Bockgård
@ 2007-11-27 23:43                   ` David Kastrup
  2007-11-28 15:27                     ` Joel J. Adamson
  1 sibling, 1 reply; 44+ messages in thread
From: David Kastrup @ 2007-11-27 23:43 UTC (permalink / raw)
  To: help-gnu-emacs

jadamson@partners.org (Joel J. Adamson) writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> So which one is the counter, "\" or "#" ?
>
> `\' and `#' together are a symbol meaning a counter in a replacement
> pattern.  `\,' is the construct that says "LISP IS COMING!"
>
> In case I failed to mention,

It is not something to be proud of:

> I often use `(string-to-int \1)' for addition, e.g.
>
> \,(+ \# (string-to-int \1))

Why don't you write \,(+ \# \#1) instead?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found] ` <mailman.4087.1196027477.18990.help-gnu-emacs@gnu.org>
@ 2007-11-28  3:36   ` cothrige
  0 siblings, 0 replies; 44+ messages in thread
From: cothrige @ 2007-11-28  3:36 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-11-25, Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
>
> 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>


Hmmm, this is quite interesting looking.  I will have to try this next
time.  If I can get that to work then it sounds like just what I am
looking for.

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]       ` <mailman.4107.1196062436.18990.help-gnu-emacs@gnu.org>
@ 2007-11-28  3:48         ` cothrige
  0 siblings, 0 replies; 44+ messages in thread
From: cothrige @ 2007-11-28  3:48 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-11-26, reader@newsguy.com <reader@newsguy.com> wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>
> So something like:
>
> img-0987.jpg
> img-9027.jpg
> img-1237.jpg
> img-0007.jpg
>
> Might become:
>
> 000-img-0987.jpg
> 001-img-9027.jpg
> 002-img-1237.jpg
> 003-img-0007.jpg
>

Yes, this is something like what I was thinking about.  Specifically,
I tend to find myself faced with a list of mp3s which are episodes in
a longer whole, perhaps a radio play.  They will look something like
this:

Paul Temple and the Gilbert Case ep 01 of 08.mp3
Paul Temple and the Gilbert Case ep 02 of 08.mp3
Paul Temple and the Gilbert Case ep 03 of 08.mp3

and so on.

What I usually want is:

01-Gilbert_Case.mp3
02-Gilbert_Case.mp3 

and such.

What I am doing now is using wdired and then using a keyboard macro to
record the moving of the 01 to the front of the file and then the
removal of the rest of file and then just replaying that 7 times for
the rest.  However, that is a bit limited to files which are identical
in terms of placement of the number.  If the files are less
consistent, and many may be, then the macro is not very useful, or at
least much, much harder to use.  For that reason I had hoped that
perhaps a more proper and flexible way may exist.

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found]         ` <mailman.4117.1196081659.18990.help-gnu-emacs@gnu.org>
@ 2007-11-28  4:17           ` cothrige
  2007-11-28  6:43             ` Thierry Volpiatto
                               ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: cothrige @ 2007-11-28  4:17 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-11-26, David Hansen <david.hansen@gmx.net> wrote:
>
> M-x wdired-change-to-wdired-mode RET
> C-M-% img RET \,(format "%03d" \#)-img RET
> !
> C-c C-c
>

Sorry for the stupid question, but how do I do the above?  Do you mean
Control-Meta-% (Control-Alt-%)?  If so, then how does one accomplish
that keystroke?  It seems to me to be the equivalent of
Control-Alt-Shift-5, and that doesn't seem to work for me (and seems
impossible for me to even do with only two hands).  How am I
misreading this?

Like I said, sorry to be dumb, but this looks like very promising, and
I just could not make it work.

Thanks for the help,

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-28  4:17           ` cothrige
@ 2007-11-28  6:43             ` Thierry Volpiatto
  2007-11-28 14:27             ` Ted Zlatanov
  2007-11-28 15:35             ` Joel J. Adamson
  2 siblings, 0 replies; 44+ messages in thread
From: Thierry Volpiatto @ 2007-11-28  6:43 UTC (permalink / raw)
  To: cothrige; +Cc: help-gnu-emacs


Hi, may be your keyboard don't support Meta key, try with ESC instead.
normally you press Control and Alt together and then (keeping pressing)
%
 
-- 
A + Thierry

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-28  4:17           ` cothrige
  2007-11-28  6:43             ` Thierry Volpiatto
@ 2007-11-28 14:27             ` Ted Zlatanov
  2007-11-28 15:35             ` Joel J. Adamson
  2 siblings, 0 replies; 44+ messages in thread
From: Ted Zlatanov @ 2007-11-28 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 28 Nov 2007 04:17:03 GMT cothrige <cothrige@yahoo.com> wrote: 

c> Do you mean Control-Meta-% (Control-Alt-%)?  If so, then how does one
c> accomplish that keystroke?  It seems to me to be the equivalent of
c> Control-Alt-Shift-5, and that doesn't seem to work for me (and seems
c> impossible for me to even do with only two hands).  How am I
c> misreading this?

Don't you know you're supposed to use your nose? :)

http://www.jargon.net/jargonfile/q/quadruplebucky.html

As a side note, while wdired is excellent and so is the advice you've
received, I should point out the mmv utility which does this kind of
renaming easily from the command line, and the analogous Z Shell zmv
function.

Ted

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-27 23:43                   ` David Kastrup
@ 2007-11-28 15:27                     ` Joel J. Adamson
  0 siblings, 0 replies; 44+ messages in thread
From: Joel J. Adamson @ 2007-11-28 15:27 UTC (permalink / raw)
  To: help-gnu-emacs

David Kastrup <dak@gnu.org> writes:

> jadamson@partners.org (Joel J. Adamson) writes:
>

[...]


>> I often use `(string-to-int \1)' for addition, e.g.
>>
>> \,(+ \# (string-to-int \1))
>
> Why don't you write \,(+ \# \#1) instead?

Because I didn't know about it.  Now I do, thanks.

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-28  4:17           ` cothrige
  2007-11-28  6:43             ` Thierry Volpiatto
  2007-11-28 14:27             ` Ted Zlatanov
@ 2007-11-28 15:35             ` Joel J. Adamson
  2007-11-28 17:18               ` cothrige
  2 siblings, 1 reply; 44+ messages in thread
From: Joel J. Adamson @ 2007-11-28 15:35 UTC (permalink / raw)
  To: help-gnu-emacs

cothrige <cothrige@yahoo.com> writes:

> On 2007-11-26, David Hansen <david.hansen@gmx.net> wrote:
>>
>> M-x wdired-change-to-wdired-mode RET
>> C-M-% img RET \,(format "%03d" \#)-img RET
>> !
>> C-c C-c
>>
>
> Sorry for the stupid question, but how do I do the above?  Do you mean
> Control-Meta-% (Control-Alt-%)?  If so, then how does one accomplish
> that keystroke?  It seems to me to be the equivalent of
> Control-Alt-Shift-5, and that doesn't seem to work for me (and seems
> impossible for me to even do with only two hands).  How am I
> misreading this?

I hold my right pinky across the Shift and Control keys, depress the
right Alt with my right thumb, and then press 5 with my left hand.

If that doesn't work, then your terminal is not accepting the keystrokes
you think it is (e.g. not accepting Shift while Alt is depressed).

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-28 15:35             ` Joel J. Adamson
@ 2007-11-28 17:18               ` cothrige
  2007-11-28 21:20                 ` cothrige
  0 siblings, 1 reply; 44+ messages in thread
From: cothrige @ 2007-11-28 17:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-11-28, Joel J. Adamson <jadamson@partners.org> wrote:
>
> I hold my right pinky across the Shift and Control keys, depress the
> right Alt with my right thumb, and then press 5 with my left hand.

Cool.  That worked.

Unfortunately, I received "Invalid use of `\' in replacement text"
Perhaps I am still misunderstanding the above commands, or maybe this
is the problem others seem to have alluded to in some of the posts
above, though I had thought that was # and not the \ itself.

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
  2007-11-28 17:18               ` cothrige
@ 2007-11-28 21:20                 ` cothrige
  0 siblings, 0 replies; 44+ messages in thread
From: cothrige @ 2007-11-28 21:20 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-11-28, cothrige <cothrige@yahoo.com> wrote:
>
> Unfortunately, I received "Invalid use of `\' in replacement text"

Oops.  Old emacs.  I upgraded to 22 and it works just fine.  And it
seems to address my needs very well.  Thanks to all for the help.

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Easy way to rename files sequentially?
       [not found] ` <mailman.4081.1196022933.18990.help-gnu-emacs@gnu.org>
@ 2007-11-29  3:29   ` cothrige
  0 siblings, 0 replies; 44+ messages in thread
From: cothrige @ 2007-11-29  3:29 UTC (permalink / raw)
  To: help-gnu-emacs

Sven Bretfeld <sven.bretfeld@gmx.ch> writes:

> I don't know a good Emacs-solution (which no doubt exists). But if you
> are under GNU, you should consider the program mmv which is most easy
> to handle and does what you want. It should be contained in the repos
> of all major distris.

Sounds interesting.  I must admit that I have never heard of it.  I will
look it up and see how it works.

Patrick

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2007-11-29  3:29 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-25 19:39 Easy way to rename files sequentially? cothrige
2007-11-25 20:35 ` Sven Bretfeld
2007-11-25 21:12 ` Eli Zaretskii
2007-11-25 21:46   ` reader
2007-11-26  3:39     ` Eli Zaretskii
2007-11-26  7:33       ` reader
2007-11-26 12:49         ` David Hansen
2007-11-26 17:56           ` reader
2007-11-26 18:26             ` David Hansen
2007-11-26 20:40               ` Eli Zaretskii
     [not found]               ` <mailman.4145.1196109649.18990.help-gnu-emacs@gnu.org>
2007-11-26 21:00                 ` David Kastrup
2007-11-26 20:08             ` Thierry Volpiatto
2007-11-27  7:07               ` Sebastian Tennant
2007-11-27  7:18                 ` Thierry Volpiatto
2007-11-27 15:14                 ` Thierry Volpiatto
2007-11-27 15:20                   ` Sebastian Tennant
2007-11-26 20:03         ` Eli Zaretskii
2007-11-27 19:31           ` reader
     [not found]           ` <mailman.4195.1196192427.18990.help-gnu-emacs@gnu.org>
2007-11-27 20:12             ` Joel J. Adamson
2007-11-27 21:35               ` Thierry Volpiatto
2007-11-27 22:00                 ` Joel J. Adamson
     [not found]                 ` <mailman.4203.1196200844.18990.help-gnu-emacs@gnu.org>
2007-11-27 23:40                   ` Johan Bockgård
2007-11-27 23:43                   ` David Kastrup
2007-11-28 15:27                     ` Joel J. Adamson
     [not found]         ` <mailman.4117.1196081659.18990.help-gnu-emacs@gnu.org>
2007-11-28  4:17           ` cothrige
2007-11-28  6:43             ` Thierry Volpiatto
2007-11-28 14:27             ` Ted Zlatanov
2007-11-28 15:35             ` Joel J. Adamson
2007-11-28 17:18               ` cothrige
2007-11-28 21:20                 ` cothrige
     [not found]       ` <mailman.4107.1196062436.18990.help-gnu-emacs@gnu.org>
2007-11-28  3:48         ` cothrige
2007-11-25 21:19 ` Xah Lee
2007-11-25 22:40   ` reader
2007-11-25 23:16     ` Peter Dyballa
2007-11-25 23:50       ` reader
2007-11-26  9:20         ` Peter Dyballa
2007-11-26 18:11           ` reader
2007-11-26 22:23             ` Peter Dyballa
2007-11-27 19:28               ` reader
2007-11-25 21:51 ` Peter Dyballa
2007-11-25 23:34   ` reader
2007-11-25 23:11 ` Bastien
     [not found] ` <mailman.4087.1196027477.18990.help-gnu-emacs@gnu.org>
2007-11-28  3:36   ` cothrige
     [not found] ` <mailman.4081.1196022933.18990.help-gnu-emacs@gnu.org>
2007-11-29  3:29   ` cothrige

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.