0

I have mp3 files of the form "Artist - Song.mp3" I create a directory for the artist, strip the artist's name from the mp3, and move the mp3 into the artist directory. Everything except for stripping the artist's name works.

#!bin/bash
for f in *.mp3
do
  artist="${f%-*}"                   #works
  song="${f%*-}"                     #Should work but it doesn't
  mkdir -m 700 ~/home/music/$artist; 
  mv "$song" ~/home/music/$artist    
  echo "artist: $artist"
  echo "song: $song"
done
Andrea Corbellini
  • 17,339
  • 3
  • 53
  • 69
Dan O'Connell
  • 119
  • 1
  • 2
  • 8

0 Answers0