batch conversion of files to lower case

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Mar 25 05:17:40 PST 2005


On 2005-03-25 03:07, Nikolas Britton <freebsd at nbritton.org> 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).



More information about the freebsd-newbies mailing list