1
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.
You mean, the former has the advantage of not creating a subshell. The latter creates a subshell with the use of parentheses. – Daniel Papasian – 2012-06-05T14:37:30.967
@DanielPapasian: It's true that the process substitution is a subshell. However, my first example creates a subshell by piping a command into the
whileand variable changes and directory changes are lost/reverted when thewhileloop terminates. The second does not create a subshell out of thewhileloop so such changes persist after thewhileloop terminates. Bash 4.2 has an optionshopt -s lastpipeto prevent the creation of a subshell in cases like the first example. Certain other shells (e.g. ksh, zsh) do not create a subshell in the circumstances represented by the first example. – Paused until further notice. – 2012-06-05T15:58:58.493