batch rename
    Dan Nelson 
    dnelson at allantgroup.com
       
    Sat Jan  5 00:08:46 PST 2008
    
    
  
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 at allantgroup.com
    
    
More information about the freebsd-questions
mailing list