Subject: Re: changing a group of file name extensions
To: None <seebs@plethora.net>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-help
Date: 05/21/1999 10:03:35
>>What would you do? What WOULD you do?
>
>for i in *.cpp
>do
> mv $i ${i%.cpp}.c
>done
nice, but i'm not that conversant with sh stuff like this.
>For extra credit
>
> ls *.cpp | while read i
> do
> j=`echo $i | tr A-Z a-z`
> mv $i ${j%.cpp}.c
> done
that's more like what i'd do. or i'd use
#!/usr/local/bin/perl
# rename script examples from lwall:
# rename 's/\.orig$//' *.orig
# rename 'y/A-Z/a-z/ unless /^Make/' *
# rename '$_ .= ".bad"' *.f
# rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
#
# shows good use of eval operator
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
and type
rename 's/.CPP$/.C/' *.CPP
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."