I opened a terminal in that folder and executed the following command.
NUM=1
for SONG in ./*
do
mv $SONG song$NUM.mp3
let NUM=NUM+1
done
So lets peek what the above script does:
- Defined a variable NUM and initialized it with 1.
- Defined a foreach loop. Here for each files in current path the for loop is executed.
- Rename(move) the file $SONG to song<num>
.mp3 - Increase the value of variable NUM by 1.
- end. ;)
mv $
SONG
song$NUM.mp3
in any way you like. But Remember the second argument to the mv command must vary for each loop, otherwise you will end up deleting all files except the last one.
3 comments:
i guess there is a quick command 'rename' for bulk renaming the files in linux.
Thanx. I was unaware of that.
Yea, rename is a real useful one
http://unstableme.blogspot.com/2008/09/bash-rename-command-rename-multiple.html
Post a Comment