From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: "\":Converting "dired-do-rename-regexp" into a "query-replace"? Date: Sat, 30 Jan 2010 17:46:45 +0100 Message-ID: <4B646275.3030005@easy-emacs.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1264869959 2917 80.91.229.12 (30 Jan 2010 16:45:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Jan 2010 16:45:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 30 17:45:56 2010 Return-path: Envelope-to: geh-help-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 1NbGSH-0005kA-Pt for geh-help-gnu-emacs@m.gmane.org; Sat, 30 Jan 2010 17:45:54 +0100 Original-Received: from localhost ([127.0.0.1]:40868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NbGSH-0002LU-D3 for geh-help-gnu-emacs@m.gmane.org; Sat, 30 Jan 2010 11:45:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NbGRt-0002Ji-7W for help-gnu-emacs@gnu.org; Sat, 30 Jan 2010 11:45:29 -0500 Original-Received: from [199.232.76.173] (port=57231 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NbGRs-0002JU-TS for help-gnu-emacs@gnu.org; Sat, 30 Jan 2010 11:45:28 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NbGRn-00007u-Ts for help-gnu-emacs@gnu.org; Sat, 30 Jan 2010 11:45:28 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.171]:54583) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NbGRn-00007g-F5 for help-gnu-emacs@gnu.org; Sat, 30 Jan 2010 11:45:23 -0500 Original-Received: from [192.168.178.27] (p54BEACB4.dip0.t-ipconnect.de [84.190.172.180]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LgL5M-1O55U51Ahg-00nfXg; Sat, 30 Jan 2010 17:45:21 +0100 User-Agent: Thunderbird 2.0.0.19 (X11/20081227) In-Reply-To: X-Provags-ID: V01U2FsdGVkX18qNwT6fQKFZ+ykH/Vol2MEnyApIcZxBsV2bUX 52RNtoGRS7NxlBHyj5UpzJYWv1CkdKvKdepza0yYGrzxXJVfse l+cEAhJiyNjfUNKEYF8dr2sBabQlt27vWLAXiPdmoc= X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71584 Archived-At: David Combs wrote: > Subj: "\\":Converting "dired-do-rename-regexp" into a "query-replace"? > > I need to turn this: > > (dired-do-rename-regexp "Lendman_1_\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_100000.mp3" "\\3\\1\\2-S.L.mp3") > > into: > > (query-replace-regexp "FROMPAT" "TO-STRING" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end))) > Hi, didn't check your forms limiting the search, assuming it works, IIUC your question, use: (while (query-replace-regexp YOUR-FIRST-REGEXP (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)) t 1) (replace-match (concat (match-string-no-properties 3) (match-string-no-properties 1) (match-string-no-properties 2) "-S.L.mp3"))) HTH Andreas -- https://code.launchpad.net/s-x-emacs-werkstatt/ > > (the dired one works fine; now I want to adjust the regexps, but test them in an ascii file, not as file-names in dired.) > > So, once I did that, how to convert it BACK into the dired-form>? > > Thanks! > > David > > > >