I have a playlist, m3u extended, formated like:

#EXTM3U
#EXTINF:213,2 Tåst - (foo bar) 
/home/www/Music/Test/test 123 - test.mp3

My problem is, that it seems the line-break is encoded as '\n\r' which makes looping over the file kind of hard:

sed '/\.mp3/s/\.mp3.*/.mp3/' test.m3u | while read line ; do cp "$line" "test/" ; done

There're also some flacs, but that's another issue... The problem with this is as follows:

cp: cannot stat `#EXTINF:125,5 /home/www/Music/Test/test 123 - test.mp3\r': No such file or directory

My two issues are: the first "`" and the terminating character '\r' are misplaced. Is there any better way to pase this in ZSH/Bash so that I can copy my playlist to my Android?

Best, www

link|improve this question
feedback

1 Answer

I'd use grep and tr instead:

grep -v '#' test.m3u | tr -d '\r' | while read line ; do cp "$line" "test/" ; done

This'll work on all files in the playlist since everything except file names and paths begins with # in a .m3u-file.

Edit: The sed way to do this is:

sed -e 's/.$//;/#/d' test.m3u |while read line ; do cp "$line" "test/" ; done

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.