LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command to rename multiple files in one go (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-rename-multiple-files-in-one-go-4175467818/)

meetvivek72 06-29-2013 08:28 AM

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..

grail 06-29-2013 08:44 AM

Have a look at the rename command or a simple for loop.

meetvivek72 06-29-2013 08:59 AM

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

jpollard 06-29-2013 09:06 AM

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.


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