From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2777 invoked from network); 18 Jun 2000 22:02:13 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Jun 2000 22:02:13 -0000 Received: (qmail 2360 invoked by alias); 18 Jun 2000 22:01:55 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3187 Received: (qmail 2352 invoked from network); 18 Jun 2000 22:01:54 -0000 To: zsh-users@sunsite.auc.dk Subject: Re: more fun with parameter expansion In-reply-to: "Clint Adams"'s message of "Fri, 16 Jun 2000 14:53:30 EDT." <20000616145330.A8031@scowler.net> Date: Sun, 18 Jun 2000 23:02:03 +0100 From: Peter Stephenson Message-Id: Clint Adams wrote: > This is for someone who wants to take a directory tree and convert all > the filenames (and directory names) to lowercase, replacing spaces > with underscores. It presumes that you are using GNU mv and have > MARK_DIRS set. I'm sure that someone can make it more efficient. > > for i (*(/N)) {mv -v "$i" "${(L)i:gs/ /_/}"} > for i (*/**/*(/N)) {mv -v "${${(L)i%/*/}:gs/ /_/}/${${${i#*/}%/}##*/}" "${(L) > i:gfor i (**/*(N^/)) {mv -v "${i}" "${(L)i:gs/ /_/}"} See zmv in the Functions/Misc directory of 3.1.9 (this version is needed for it to work). zmv '(**/)(*[ A-Z]*)' '${1}${(L)2/ /_}' works on a simple test case (use the option -n just to test what it would do). Each parenthesis maps to a positional parameter; (**/) is a special case and is the only sort of multi-directory pattern that works. Looks like zmv needs the option to ignore files whose names didn't change (it's a pain having to make the LH pattern so specific). I'd appreciate any feedback about zmv. -- Peter Stephenson Work: pws@CambridgeSiliconRadio.com Web: http://www.pwstephenson.fsnet.co.uk