From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#6823: 24.0.50; Wdired or Dired enhancement Date: Mon, 09 Aug 2010 07:50:31 +0200 Organization: ThierryVolpiatto Message-ID: <87pqxs5o7s.fsf@tux.homenetwork> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1281334122 12882 80.91.229.12 (9 Aug 2010 06:08:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 9 Aug 2010 06:08:42 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 09 08:08:41 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OiLXM-0005lY-KD for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Aug 2010 08:08:40 +0200 Original-Received: from localhost ([127.0.0.1]:44498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiLXL-0002vh-6R for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Aug 2010 02:08:39 -0400 Original-Received: from [140.186.70.92] (port=49466 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiLXB-0002vc-D8 for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 02:08:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiLX5-0001o5-61 for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 02:08:29 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38212) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiLX5-0001o0-3L for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 02:08:23 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OiLIE-0002rx-AW; Mon, 09 Aug 2010 01:53:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Aug 2010 05:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6823 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.128133316211023 (code B ref -1); Mon, 09 Aug 2010 05:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Aug 2010 05:52:42 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiLHu-0002rk-DZ for submit@debbugs.gnu.org; Mon, 09 Aug 2010 01:52:42 -0400 Original-Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiLHr-0002rf-UL for submit@debbugs.gnu.org; Mon, 09 Aug 2010 01:52:40 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:38715) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OiLIW-00021Z-F2 for submit@debbugs.gnu.org; Mon, 09 Aug 2010 01:53:20 -0400 Original-Received: from [140.186.70.92] (port=36756 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiLIV-0001A7-1y for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 01:53:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiLIT-0008IF-J5 for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 01:53:18 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:41422) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiLIT-0008He-9U for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 01:53:17 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OiLIP-000229-Lr for bug-gnu-emacs@gnu.org; Mon, 09 Aug 2010 07:53:13 +0200 Original-Received: from 173.77.197-77.rev.gaoland.net ([77.197.77.173]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 Aug 2010 07:53:13 +0200 Original-Received: from thierry.volpiatto by 173.77.197-77.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 Aug 2010 07:53:13 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 69 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 173.77.197-77.rev.gaoland.net User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:11gQiYPvHiPdMYzoeCrPrpu7uSg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 09 Aug 2010 01:53:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39346 Archived-At: Hi Drew, "Drew Adams" 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