Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-19-2007, 09:12 AM   #1
LQ Newbie
Registered: Jun 2006
Posts: 17

Rep: Reputation: 0
Renaming multiple files

I need to rename multiple files. Can anyone write be a simple script?
I want to replace only certain portion of the file name. For example, in the file name "James_Bond_007_axial image.jpg" I want to replace only the name James_Bond with say George_Bush, leaving 007_axial image.jpg intact.

I have tried mmv and mvb renaming programs but don't know exactly how to word the script.

Old 01-19-2007, 09:51 AM   #2
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
Here's one way to do it:

for i in *_axial image.jpg; do mv $i 
`echo $i | sed -e s/_axial image.jpg/whatever_you_want_to_rename_to/`; done;
Assuming you're in the directory with the files you want to rename. If not change *_axial image.jpg to /wherever/*_axial image.jpg.
Old 01-19-2007, 11:04 PM   #3
LQ Newbie
Registered: Jun 2006
Posts: 17

Original Poster
Rep: Reputation: 0
thanks so much. It worked.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming multiple files linuxhippy Slackware 10 01-21-2011 01:53 AM
Linux 101 - Renaming Multiple Files ????? perry Linux - Newbie 3 04-08-2006 09:09 PM
renaming multiple files in general kkatebian Linux - General 5 11-06-2005 11:05 AM
Renaming multiple files with the same format Shr00mBoXx Slackware 7 06-20-2004 07:22 PM
Solution: renaming multiple files with spaces HawkeyeCoug Linux - Newbie 0 03-26-2004 10:57 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:19 AM.

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