Click to See Complete Forum and Search --> : Need help renaming multiple files


bookman761
12-20-2007, 07:20 PM
Hi,

I have a collection of mp3 files that I would like to rename. I want to simply add a prefix to my files such as;

hotel california.mp3 >>>>> eagles-hotel california.mp3

How do I do this to multiple files????

Do you know the rename command or mv command and its options to do this in the terminal for multiple files?

Thanks,
FG

whitewater3505
12-20-2007, 09:27 PM
The best way to do that is to use regular expressions in a shell script. It could be a long script depending on your organization of your files.

If you have your Artists in separate directories, it would make the script way shorter. Else the script would be very very difficult to write. How does your music directory look?

P.S. Great Song!!! My favorite one to listen to while programming....

happybunny
12-20-2007, 10:46 PM
rename

used it just yesterday http://www.nongnu.org/renameutils/

whitewater3505
12-20-2007, 11:35 PM
O wow I was starting to make a program to do that. No need for that now. That is neat! Thanks happybunny

Bryon Speede
12-21-2007, 12:02 PM
for i in *.mp3; do
mv "$i" "eagles-$i"
done

edit, added quotes to account for spaces.

happybunny
12-21-2007, 12:25 PM
i think:

$ rename 's/^/Eagles-/g' *