Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: capitalizing file names



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