LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   basename counterpart? (http://www.linuxquestions.org/questions/linux-general-1/basename-counterpart-28660/)

glass 08-23-2002 11:06 PM

basename counterpart?
 
Howdy,
I'm trying to change a relatively large group of files' extensions. I can remove the current extensions with basename I think, but I need a counterpart to add the correct extension.
-Eric

Hko 08-24-2002 06:11 AM

One way to do this:

Change to the directory where your to-be-renamed files are, and enter (in bash):
Code:

OLDEXT="cc"
NEWEXT="cpp"
for i in *.$OLDEXT ; do mv "$i" "${i%.*}.$NEWEXT" ; done

Where you should change the extensions ("cc" and "cpp") to your own needs of course.


All times are GMT -5. The time now is 04:35 AM.