Using Amarok Generated Playlists (m3u) on Sansa Clip

Few days ago, for the first time, I’ve created a playlist using Amarok for files on my Sansa Clip player. To my surprise (and disappointment) when I’ve unplugged my Sansa Clip and powered it, the playlist showed up empty, unlike playlists which originated in Windows. As I keep my music collection organized in Amarok, the situation seemed to be very uncomfortable.

I’ve decided to compare one of the working playlist files and the “empty” Amarok generated playlist. Two things were noticeable:

  1. Amarok uses forward slashes, like in a Linux environment, and the working playlist used backward slashes.
  2. The working playlist used relative paths without any prefix – directly beginning with the path. Amarok prefixed the relative paths with a dot-slash (./).

After noticing those things I’ve modified my Amarok generated playlist to look like the Windows generated one, and voila, it worked. I tried going through Amarok’s configuration dialogs to find some option controlling the format of generated m3u playlists, but couldn’t find any (I’m using Amarok 1.4.10). So with my newly found wits I’ve looked for a way to make using the playlists easier. I’ve came up with the following one-liner:

find -name "*.m3u" | xargs -I{} sed "s/^\.\///;s/\//\\\\/g" -i'' {}

The command should be run in the MUSIC directory of the Sansa Clip’s filesystem. It recursivey looks for m3u playlists and for each one strips any leading dot-slash and replaces forward slashes with backward ones. It can be used to easily convert all your playlists to the format understandable by Sansa Clip.

3 thoughts on “Using Amarok Generated Playlists (m3u) on Sansa Clip

  1. Junior

    Sed dosen’t need to use “/” for seperation. I believe any character will work. So especially when the pattern or replacemnt involves a “/”, it’s sensible to use something else. I use a “-”. The “\” still need so be escaped though. Just makes it easier to read.
    sed ‘s-^./–;s-/-\\-g’

    I also had to add a line with
    to the beginning of the playlist. Or maybe that wasn’t from Amarok… Anyway, I sure like my Clip with it’s good sound and ability to play ogg and flac files!

  2. Dazed

    Man, you are awesome. Thanks. A lot. I stored that one liner as “sansatize” in my bash.rc-

    Makes life a lot easier.

  3. Tommy Stanton

    Excellent post, thanks for the helpful tip!

    Related to what Junior suggested, I used your idea and created a shell function. I put these lines in my ~/.bashrc:

    sansa-m3u () {
    sed ‘s|^\./||;s|/|\\|g’ -i” “$@”

    Then (after using “. ~/.bashrc” to source it) all I had to do was:
    $ sansa-m3u *.m3u

    …before deploying the playlists to my Sansa.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>