LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-29-2013, 08:28 AM   #1
meetvivek72
LQ Newbie
 
Registered: Jun 2013
Posts: 2

Rep: Reputation: Disabled
Arrow Command to rename multiple files in one go


Hi all,



I have few directories containing around 96 files each. All I want to rename those 96 files names...Example of filenames is shown below:::

TaeCsp2AS_1635B03.fsa
TaeCsp2AS_1635B04.fsa
TaeCsp2AS_1635B05.fsa
TaeCsp2AS_1635B06.fsa
TaeCsp2AS_1635A11.fsa
TaeCsp2AS_1635A12.fsa
TaeCsp2AS_1635C06.fsa
TaeCsp2AS_1635C04.fsa

here I want their names to be like

TaeCsp2AS_1635_B03.fsa
TaeCsp2AS_1635_B04.fsa
TaeCsp2AS_1635_B05.fsa
TaeCsp2AS_1635_B06.fsa
TaeCsp2AS_1635_A11.fsa
TaeCsp2AS_1635_A12.fsa
TaeCsp2AS_1635_C06.fsa
TaeCsp2AS_1635_C04.fsa
it only need to replace TaeCsp2AS_1635 with TaeCsp2AS_1635_ i.e, we have to append a _ with 1635..
 
Old 06-29-2013, 08:44 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Have a look at the rename command or a simple for loop.
 
Old 06-29-2013, 08:59 AM   #3
meetvivek72
LQ Newbie
 
Registered: Jun 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
m newbiw here , tried a lot ,, got many commands to rename single file, but didn't get any usefull one for renaming bunch of files simultaneously
 
Old 06-29-2013, 09:06 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
man rename

Basically - "rename <expression> <replacement> <file>...", and the ... is for multiple files

Code:
...
DESCRIPTION
       rename  will  rename  the specified files by replacing the first occur‐
       rence of expression in their name by replacement.
...
so your sample would imply that "rename TaeCsp2AS_1635 TaeCsp2AS_1635_ TaeCsp2AS_1635*"
should do the job.
 
  


Reply



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
[SOLVED] rename multiple files lghizoni Linux - Newbie 7 01-30-2013 08:48 AM
Shell command to rename multiple archives lghizoni Linux - General 2 05-22-2012 12:35 PM
Rename multiple files L1nuxn00b703 Linux - Newbie 4 04-11-2012 02:30 AM
rename multiple files tjay1983 Programming 3 08-10-2010 12:43 AM
How to rename multiple files? Rostfrei Linux - Newbie 3 07-11-2006 06:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration