Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: capitalizing file names
- X-seq: zsh-users 11454
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: capitalizing file names
- Date: Wed, 25 Apr 2007 22:52:37 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=first1; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=Ubrc9vN/fQw7lBwuML5jp7SwHWt0wEt+xKtlI52vm+dQqrNl7hrlpHHe6eLQLO3rpatT4rvicFYRKcR/o6ykOVBPgl6+mdKptFRXNnfbpIhiuBz5DDgk0TdlMcbIoAQHPPYEKXt4wenw0XYNRXqTgxAnYMMKt8AwfBW9nKu0S1g=;
- In-reply-to: <7c737f300704252216qc8cf271y9966c1a4e2655f1@xxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <7c737f300704252216qc8cf271y9966c1a4e2655f1@xxxxxxxxxxxxxx>
On 2007-04-25 at 22:16 -0700, Alexy Khrabrov wrote:
> I need to rename a series of files on Mac OS X, to reflect case
> difference. I have multi-word file names such as
>
> alexy_070411_1971.dng
>
> -- which must become
>
> Alexy_070411_1971.DNG
>
> -- that is, I need to capitalize the filename and the extension. Lest
> of writing a perl/ruby script, is there a zsh way?
If you can assume that all filenames have an extension:
for f in ...whatever...
do
mv $f ${(C)f:r}.${(U)f:e}
done
See zshexpn(1); (C) to capitalise words, (U) to upper-case them, :r and
:e for extracting components of the filename (root & extension).
Successfully tested on MacOS X.
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author