I'm trying to write a short script that changes the file names in the folders containing music (mp3) files. The current format is often along the lines of:
"Artist Name - Album Name - tracknum - Trackname.mp3"
and I'd like to shorten this to just:
"tracknum Trackname.mp3"
So, I've tried the following approach
Code:
for i in *.mp3; do
j=`echo $i | cut -d "-" -f3`; #results in "tracknum"
k=`echo $i | cut -d "-" -f4`; #results in "Trackname.mp3"
mv $i $j$k;
done
but I get the error:
Code:
mv: target `Trackname.mp3' is not a directory
I'm not expecting it to be a directory! As far as I'm aware, $j$k should give me "tracknum Trackname.mp3". Indeed, this is the result of
Could someone please tell me where I'm going wrong or how to solve my problem?
Cheers