Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: more fun with parameter expansion
- X-seq: zsh-users 3187
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: more fun with parameter expansion
- Date: Sun, 18 Jun 2000 23:02:03 +0100
- In-reply-to: "Clint Adams"'s message of "Fri, 16 Jun 2000 14:53:30 EDT." <20000616145330.A8031@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxxxxxxxxxxxxxxxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk
Messages sorted by:
Reverse Date,
Date,
Thread,
Author