LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-23-2002, 11:06 PM   #1
glass
LQ Newbie
 
Registered: Nov 2001
Distribution: redhat 7.3 (currently)
Posts: 9

Rep: Reputation: 0
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
 
Old 08-24-2002, 06:11 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dirname basename; how to capture extensions from bash? carl0ski Linux - General 2 07-22-2005 07:26 AM
Invert to Basename strip filename carl0ski Programming 2 07-03-2005 02:36 AM
ar counterpart for dynamic share libraries ? colmmagoo Linux - Software 0 08-06-2004 02:36 PM
BASH scripting problem, spaces in filenames / using basename textures Programming 24 11-16-2003 01:41 AM
any counterpart of mke2fs for cramfs aditya Linux - General 1 09-10-2002 05:02 AM


All times are GMT -5. The time now is 07:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration