Using Amarok Generated Playlists (m3u) on Sansa Clip

A few days ago, for the first time, I created a playlist using Amarok for files on my Sansa Clip player. To my surprise (and disappointment), when I unplugged my Sansa Clip and powered it on, the playlist showed up empty, unlike playlists that originated in Windows. As I keep my music collection organized in Amarok, the situation seemed 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 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 I 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 come 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 recursively 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 the Sansa Clip.