Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2008 02:08:45 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Jeff Laine <wtf.jlaine@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: batch rename
Message-ID:  <20080105080845.GG52545@dan.emsphone.com>
In-Reply-To: <2b98f2f70801042134x1af4f721s877677afde7151f5@mail.gmail.com>
References:  <2b98f2f70801042134x1af4f721s877677afde7151f5@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jan 05), Jeff Laine said:
> My goal is to rename several files in such a way as to decapitalize
> starting letters in their names. The solution seems to be simple but
> I'm stuck. What should I use? awk/sed or write some shell-script?

Best way is with ports/misc/mmv:
 
  mmv "?*" "=l1=2"

If you use zsh, you can use the zmv function to do the same thing:

 autoload -U zmv
 zmv '([A-Z])(*)' '${(L)1}$2'

Both of the above will detect filename collisions and tell you what
won't work.  If you know there aren't any collisions, you could do this
(zsh again):

 for i in [A-Z]* ; do
   mv $i ${i[1]:l}${i[2,-1]}
 done

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080105080845.GG52545>