Posted 2006-02-07T21:41:00+01:00 in unix recipe
Quick note to remember my favorite way to rename a bunch of music files. I write a text file with all the titles. Each line contains two fields. The first field is generated by cdparanoia and oggenc when I rip the track from the audio cd. The second field contains the name I want to name the file. It's easy to write this down in a separate text file first, so that I can correct spelling errors more easily.
The bottom script is a simple Bash script that renames each file from the first field on the line to the second field on the line in the text file.
jeroenp@quadrupel$ cat titles
track01.cdda.ogg:(Oasis) (Definitely Maybe) (01) Rock n Roll Star.ogg
track02.cdda.ogg:(Oasis) (Definitely Maybe) (02) Shakermaker.ogg
track03.cdda.ogg:(Oasis) (Definitely Maybe) (03) Live Forever.ogg
track04.cdda.ogg:(Oasis) (Definitely Maybe) (04) Up In The Sky.ogg
track05.cdda.ogg:(Oasis) (Definitely Maybe) (05) Columbia.ogg
track06.cdda.ogg:(Oasis) (Definitely Maybe) (06) Supersonic.ogg
track07.cdda.ogg:(Oasis) (Definitely Maybe) (07) Bring It On Down.ogg
track08.cdda.ogg:(Oasis) (Definitely Maybe) (08) Cigarettes And Alcohol.ogg
track09.cdda.ogg:(Oasis) (Definitely Maybe) (09) Digseys Dinner.ogg
track10.cdda.ogg:(Oasis) (Definitely Maybe) (10) Slide Away.ogg
track11.cdda.ogg:(Oasis) (Definitely Maybe) (11) Married With Children.ogg
jeroenp@quadrupel$ cat titles | while read line
do mv "${line%:*}" "${line/*.ogg:/}" done