0

I would like to rename files from a list. This is the file format:

Original name

New name

000000000000402a.ogg
Dth_BrkNck_FOD_MALE_MALE_001
000000000000402c.ogg
Dth_BrkNck_FOD_MALE_MALE_002
000000000000402e.ogg
Dth_BrkNck_FOD_MALE_MALE_003
0000000000004030.ogg
Dth_BrkNck_FOD_MALE_MALE_004

I'm kinda new to shell scripts, so any help will be appreciated. Thank you.

Notex
  • 1
  • Forget about the shell or scripting for a while - how would *you* go about doing it, if you were to do it by hand? Once you have a plan ready, then it's all about scripting to that plan *SCNR* :-) – S.R.I Dec 05 '17 at 09:59
  • That said, did you take a look at [this SO question](https://stackoverflow.com/questions/1086502/rename-multiple-files-in-unix)? – S.R.I Dec 05 '17 at 10:02
  • 1
    Possible duplicate of [Rename multiple files in Unix](https://stackoverflow.com/questions/1086502/rename-multiple-files-in-unix) – S.R.I Dec 05 '17 at 10:02
  • Welcome to Stack Overflow. Please read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). Research, try something, add your code & point your problem. – pirho Dec 05 '17 at 10:12

1 Answers1

0

Seems like there is not direct connection b/w Original file name and New file name, To rename a file,

mv OriginalName NewName

one way is to repeat the step for multiple files, ( we can create all commands in a notepad and paste it altogether) or we can put it in a shell script , say renamer.sh as below and execute it,

cat renamer.sh
mv 000000000000402a.ogg Dth_BrkNck_FOD_MALE_MALE_001
mv 000000000000402c.ogg Dth_BrkNck_FOD_MALE_MALE_002
mv 000000000000402e.ogg Dth_BrkNck_FOD_MALE_MALE_003
mv 0000000000004030.ogg Dth_BrkNck_FOD_MALE_MALE_004

to execute :- sh renamer.sh

Jithin Scaria
  • 1,271
  • 1
  • 15
  • 26