From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26053 invoked from network); 12 Jun 1998 10:08:05 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Jun 1998 10:08:05 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id GAA22343; Fri, 12 Jun 1998 06:03:54 -0400 (EDT) Resent-Date: Fri, 12 Jun 1998 06:03:45 -0400 (EDT) To: zsh-users@math.gatech.edu Subject: Re: help with 'rename' function References: <199806120816.EAA22173@luomat.peak.org> Mime-Version: 1.0 (generated by tm-edit 7.108) Content-Type: text/plain; charset=US-ASCII From: Hannu Koivisto Date: 12 Jun 1998 12:55:40 +0300 In-Reply-To: Timothy J Luoma's message of "Fri, 12 Jun 98 04:15:57 -0400" Message-ID: <87solb3pwj.fsf@quasar.vvf.fi> X-Mailer: Gnus v5.5/XEmacs 20.4 - "Emerald" Resent-Message-ID: <"ucWbG1.0.dS5._pFWr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1596 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Timothy J Luoma writes: | For example, say you have a bunch of files which ended with .THIS and you | wanted to change them to end with .THAT | | You would do | | rename *.THIS THIS=THAT | | and it would go on its way... or if it was just one file: | | rename foo.THIS THIS=THAT Well, I needed to do exactly this but also do other arbitrary rename operations to one or many files, so I first created a "higher-order" ;) function... rename-with-filter () { if ! [[ $# -lt 2 ]] then for kala in $argv[2,-1] do mv "$kala" "$(echo "$kala" | eval $1)" done fi } ...using which I could make, for example, a following kind of function to transform filenames like ThisIsFilename to This_Is_Filename: rename_separate () { rename-with-filter "sed -e 's/\([a-z]\)\([A-Z]\)/\1_\2/g'" $* } This should handle your much simpler case too. | I've tried to make a function which does this, but it fails: Sorry, can't help you with your implementation, I'm pretty much write-only zsh user :) //Hannu