GNU bug report logs - #6823
24.0.50; Wdired or Dired enhancement

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Sun, 8 Aug 2010 17:15:02 UTC

Severity: wishlist

Found in version 24.0.50

To reply to this bug, email your comments to 6823 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Sun, 08 Aug 2010 17:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 08 Aug 2010 17:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.0.50; Wdired or Dired enhancement
Date: Sat, 7 Aug 2010 11:37:43 -0700
Emacs sorely needs one or more commands that let you rename the
marked files as a sequence (following a pattern).
 
See MS Windows for an example (but we could do better):
 
1. You sort the file list the way you want, to put the files you want to
act on in the right order.  Especially with libraries such as Francis
Wright's `dired-sort-menu.el', you can sort Dired in many different
ways.
 
2. You mark the files you want to rename.  (In Windows you select them.)
 
3. You invoke a rename command, and enter a pattern for the new names.
The pattern includes an optional starting index, which is a whole
number.  In Windows you put the index in parens, which are included in
the file names.  Example: `new name (100)'.  The marked files are named
`new name (100)', `new name (101)'...
 
Obviously, in Emacs we could provide for better patterns and
substitutions than this.  But AFAIK today we offer nothing like this.

If you have 1000 family photo files you want to rename to something like
`2010 Summer Vacation (1000)', `2010 Summer Vacation (1001)' etc. (or
even just `1000', `1001'...), then AFAIK the best you can do now is to
use Wdired and perform query-replace with some fancy replacement
expression.  We should offer something simpler for the common task of
renaming a sequence of files.

 
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-08-02 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/xpm/include'
 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 02:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 6823 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 6823 <at> debbugs.gnu.org
Subject: Re: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 09 Aug 2010 05:59:15 +0300
> From: "Drew Adams" <drew.adams <at> oracle.com>
> Date: Sat, 7 Aug 2010 11:37:43 -0700
> Cc: 
> 
> Emacs sorely needs one or more commands that let you rename the
> marked files as a sequence (following a pattern).

Doesn't the "% R" command in Dired use query-replace under the hood?
If so, doesn't it already allow to include Lisp expressions in the
replacement that are eval'ed?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 05:53:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 09 Aug 2010 07:50:31 +0200
Hi Drew,

"Drew Adams" <drew.adams <at> oracle.com> writes:

> Emacs sorely needs one or more commands that let you rename the
> marked files as a sequence (following a pattern).
>  
> See MS Windows for an example (but we could do better):
>  
> 1. You sort the file list the way you want, to put the files you want to
> act on in the right order.  Especially with libraries such as Francis
> Wright's `dired-sort-menu.el', you can sort Dired in many different
> ways.
>  
> 2. You mark the files you want to rename.  (In Windows you select them.)
>  
> 3. You invoke a rename command, and enter a pattern for the new names.
> The pattern includes an optional starting index, which is a whole
> number.  In Windows you put the index in parens, which are included in
> the file names.  Example: `new name (100)'.  The marked files are named
> `new name (100)', `new name (101)'...
>  
> Obviously, in Emacs we could provide for better patterns and
> substitutions than this.  But AFAIK today we offer nothing like this.
>
> If you have 1000 family photo files you want to rename to something like
> `2010 Summer Vacation (1000)', `2010 Summer Vacation (1001)' etc. (or
> even just `1000', `1001'...), then AFAIK the best you can do now is to
> use Wdired and perform query-replace with some fancy replacement
> expression.  We should offer something simpler for the common task of
> renaming a sequence of files.

We have have two tools to achieve this, wdired-change-to-wdired-mode,
and query-replace-regexp used with \, and \# in the replacement regexp.

,----
| E.g: (in dired)
| C-x C-q
| C-M-%
| ==> [A-Za-z0-9]*.jpg
| ==> 2010-summer-vaccation-\,(format "1%03d" \#).jpg
`----

You can use also this function:(You may have to run it two times in some
rare cases)

,----
| (defun serial-rename (dir ext name start)
|   "rename all the files of DIR matching regex EXT with the name NAME \
| starting to number START - ex: file01.jpg"
|   (interactive "Ddir: \nsExt(no dot): \nsName: \nnStart: ")
|   (find-file dir)
|   (let* ((ls-dir     (file-expand-wildcards (format "*.%s" ext) t))
|          (new-ls-dir (loop with len = (length ls-dir) 
|                         repeat len for count from start
|                         for fnum = (if (< start 10) "0%s" "%s")
|                         collect (concat dir name (format fnum count) "." ext))))
|     (loop for i in ls-dir for index from 0
|        for new-name = (nth index new-ls-dir)
|        unless (file-exists-p new-name) do (rename-file i new-name)))
|   (revert-buffer nil t nil))
`----



-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 06:11:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 09 Aug 2010 08:08:10 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: "Drew Adams" <drew.adams <at> oracle.com>
>> Date: Sat, 7 Aug 2010 11:37:43 -0700
>> Cc: 
>> 
>> Emacs sorely needs one or more commands that let you rename the
>> marked files as a sequence (following a pattern).
>
> Doesn't the "% R" command in Dired use query-replace under the hood?
> If so, doesn't it already allow to include Lisp expressions in the
> replacement that are eval'ed?

It seem "%R" rename only files matching regexp to newname but
doesn't allow the use of "\," and "\#" in the regexp replacement like
query-replace-regexp does.

>
>
>

-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 14:04:02 GMT) Full text and rfc822 format available.

Message #17 received at 6823 <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Eli Zaretskii'" <eliz <at> gnu.org>
Cc: 6823 <at> debbugs.gnu.org
Subject: RE: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 9 Aug 2010 07:02:30 -0700
> > Emacs sorely needs one or more commands that let you rename the
> > marked files as a sequence (following a pattern).
> 
> Doesn't the "% R" command in Dired use query-replace under the hood?
> If so, doesn't it already allow to include Lisp expressions in the
> replacement that are eval'ed?

That kind of thing is what I had in mind when I said (though I mentioned Wdired,
not Dired):

>> AFAIK the best you can do now is to use Wdired and perform
>> query-replace with some fancy replacement expression

The Windows behavior does not require any use of a fancy replacement expression
(Lisp).

Again, we can do better than Windows does, and it is good to also offer fancy
replacement (e.g. Lisp sexps).  But we should also offer something as simple as
Windows does, and not _require_ users who want to do this kind of common
renaming to work their way through Lisp replacement sexps (no matter how simple
the sexp might be).

In addition, we should probably advertise this renaming better (even %R in
Dired), in the Dired/Wdired doc.  If %R is the best we can do for now, then
perhaps add a very simple, short example to illustrate the kind of renaming I
mentioned.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 14:16:01 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Thierry Volpiatto'" <thierry.volpiatto <at> gmail.com>,
	<bug-gnu-emacs <at> gnu.org>
Subject: RE: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 9 Aug 2010 07:16:01 -0700
> > AFAIK the best you can do now is to use Wdired and perform
> > query-replace with some fancy replacement expression.
> > We should offer something simpler for the common task of
> > renaming a sequence of files.
> 
> We have have two tools to achieve this, wdired-change-to-wdired-mode,
> and query-replace-regexp used with \, and \# in the 
> replacement regexp.

That's exactly what I meant by "use Wdired and perform query-replace with some
fancy replacement expression."

I know that a user can do it.  What I suggest is that we also "offer something
simpler for the common task of renaming a sequence of files."

A Windows user need not be familiar with Lisp sexps (and especially arcane
incantations using `\,' and \#).  It's great to have that capability, but we
should also offer something simpler for the common, simple case.

> You can use also this function:(You may have to run it two 
> times in some rare cases)
>
>  (defun serial-rename (dir ext name start)...

I haven't tried it, but from the doc string, it sounds like the kind of thing I
had in mind.

The doc for Dired should mention such a command (which should be bound to a
key), and it should mention that you can do fancier, more flexible replacement
using query-replace with `\,', `\#', etc.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6823; Package emacs. (Mon, 09 Aug 2010 14:51:02 GMT) Full text and rfc822 format available.

Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6823: 24.0.50; Wdired or Dired enhancement
Date: Mon, 09 Aug 2010 16:48:26 +0200
"Drew Adams" <drew.adams <at> oracle.com> writes:

>> > AFAIK the best you can do now is to use Wdired and perform
>> > query-replace with some fancy replacement expression.
>> > We should offer something simpler for the common task of
>> > renaming a sequence of files.
>> 
>> We have have two tools to achieve this, wdired-change-to-wdired-mode,
>> and query-replace-regexp used with \, and \# in the 
>> replacement regexp.
>
> That's exactly what I meant by "use Wdired and perform query-replace with some
> fancy replacement expression."

Ah! yes sorry.

> I know that a user can do it.  What I suggest is that we also "offer something
> simpler for the common task of renaming a sequence of files."
>
> A Windows user need not be familiar with Lisp sexps (and especially arcane
> incantations using `\,' and \#).  It's great to have that capability, but we
> should also offer something simpler for the common, simple case.

Maybe have a special command for wdired that start wdired-mode but
provide a special regexp template for this case to give to
query-replace.

What is good with wdired+query-replace is we can undo if regexp is
wrong until we find a good regexp.

>> You can use also this function:(You may have to run it two 
>> times in some rare cases)
>>
>>  (defun serial-rename (dir ext name start)...
>
> I haven't tried it, but from the doc string, it sounds like the kind of thing I
> had in mind.
>
> The doc for Dired should mention such a command (which should be bound to a
> key), and it should mention that you can do fancier, more flexible replacement
> using query-replace with `\,', `\#', etc.
>
This command (serial-rename) is not part of emacs, it's just a little
command of my config i use sometime to rename quickly my photos.
However i prefer wdired/query-replace-regexp.

-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




This bug report was last modified 14 years and 311 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.