Moving symlinks into a folder based on id3 tags.

Posted by Reti on Super User See other posts from Super User or by Reti
Published on 2010-04-03T01:35:49Z Indexed on 2010/04/03 1:43 UTC
Read the original article Hit count: 438

Filed under:
|
|
|
|

I'm trying to get my music folder into something sensible. Right now, I have all my music stored in /home/foo so I have all of the albums soft linked to ~/music. I want the structure to be ~/music/<artist>/<album> I've got all of the symlinks into ~/music right now so I just need to get the symlinks into the proper structure. I'm trying to do this by delving into the symlinked album, getting the artist name with id3info. I can do this, but I can't seem to get it to work correctly.

for i in  $( find -L $i -name "*.mp3" -printf "%h\n")
do

 echo "$i" #testing purposes

    #find its artist
    #the stuff after read file just cuts up id3info to get just the artist name
 #$artist = find -L $i -name "*.mp3" | read file; id3info $file | grep TPE | sed "s|.*: \(.*\)|\1|"|head -n1

 #move it to correct artist folder
 #mv "$i" "$artist"

done

Now, it does find the correct folder, but every time there is a space in the dir name it makes it a newline.

Here's a sample of what I'm trying to do

$ ls 
DJ Exortius/
The Trance Mix 3 Wanderlust - DJ Exortius [TRANCE DEEP VOCAL TECH]@

I'm trying to mv The Trance Mix 3 Wanderlust - DJ Exortius [TRANCE DEEP VOCAL TECH]@ into the real directory DJ Exortius. DJ Exortius already exists, so it's just a matter of moving it into the correct directory that's based on the id3 tag of the mp3 inside.

Thanks!

PS: I've tried easytag, but when I restructure the album, it moves it from /home/foo which is not what I want.

© Super User or respective owner

Related posts about bash

Related posts about linux