zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-users@sunsite.auc.dk
Subject: Re: more fun with parameter expansion
Date: Sun, 18 Jun 2000 23:02:03 +0100	[thread overview]
Message-ID: <E133n8a-00040G-00.2000-06-18-23-01-52@cmailg5.svr.pol.co.uk> (raw)
In-Reply-To: "Clint Adams"'s message of "Fri, 16 Jun 2000 14:53:30 EDT." <20000616145330.A8031@scowler.net>

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 <pws@pwstephenson.fsnet.co.uk>
Work: pws@CambridgeSiliconRadio.com
Web: http://www.pwstephenson.fsnet.co.uk


  parent reply	other threads:[~2000-06-18 22:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-16 18:53 Clint Adams
2000-06-16 19:54 ` Clint Adams
2000-06-16 21:00 ` Bart Schaefer
2000-06-16 21:44   ` Bart Schaefer
2000-06-17  1:17     ` Clint Adams
2000-06-18 22:02 ` Peter Stephenson [this message]
2000-06-19  9:08   ` Peter Stephenson
2000-06-19 15:21     ` Clint Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E133n8a-00040G-00.2000-06-18-23-01-52@cmailg5.svr.pol.co.uk \
    --to=pws@pwstephenson.fsnet.co.uk \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).