banner

Strip the first part of a filename out

I created this little program to help me organize my music. My software had created it with the artist name appended to the front, followed by a dash and then the song title. After I reorganized the files into directories, I no longer needed the artist name in front of the song. So I created the following script and used it to strip the names out. I used it like this...

$ stripname "The Cars - "

Here is the script.

#!/bin/bash
for file in *.mp3; do
target=$(echo $file | sed -e "s/$1//")
mv "$file" "$target"
done
echo
echo
ls