Re: batch conversion of files to lower case

Giorgos Keramidas <[email protected]> Fri, 25 Mar 2005 15:17:29 +0200
Newsgroups gmane.os.freebsd.newbies
Message-ID <[email protected]>
On 2005-03-25 03:07, Nikolas Britton <[email protected]> wrote:
> Posting this here so I can find it next time I need. Converts files in
> a directory to lower-case, change "*.TTF" to whatever you want to find
> / change:
>
> find ./ -name "*.TTF" -exec perl -e 'rename($_, lc) || warn "$_: $!\n"
> for @ARGV' {} \;

In true Perl spirit (TMTOWTDI, etc.) I usually map{} arrays instead of
iterating over them with for loops and am a great fan of xargs:

	find . -name "*.TTF" | \
	xargs perl -e 'map{rename($_,lc) || warn "$_: $!\n"} @ARGV'

Cool trick though.  It has been my favorite way of mass-renaming files
for a long time.  It's faster to check and harder to get wrong than the
equivalent echo/sed/mv stuff in sh(1).

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-newbies
To unsubscribe, send any mail to "[email protected]"