Date: Sat, 5 Jan 2008 12:12:58 +0100 From: Michel Talon <talon@lpthe.jussieu.fr> To: freebsd-questions@freebsd.org Subject: Re: batch rename Message-ID: <20080105111258.GA4180@lpthe.jussieu.fr>
next in thread | raw e-mail | index | archive | help
Aryeh M. Friedman wrote: > 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? > > This assumes tcsh: > > foreach i (`ls [A-Z][a-z]*`) > mv $i `echo $i|tr 'A-Z' 'a-z'` > end This will disfunction if the names have embedded white spaces. I happen to batch rename songs etc. which almost invariably have white spaces and other horrors. So i use something like mv "$i" `echo $i|sed -e 's/ */_/g' -e '.....' ` Sed has the advantage you can do several transformations at one stroke, and fine tune the transformations. Double quotes avoid that the shell breaks names on white space. -- Michel TALON
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080105111258.GA4180>