Changing the Order of Music Files on an SD Card

It turns out that prefixing the track number onto my music files did not fix the problem with the way my car stereo plays them. It turns out that the Pioneer does not play them in alphabetical order, but the actual order that they appear on the drive. The same order you would get if you just ran “find” with no arguments on Linux.

To fix this is fairly easy, just read the files in alphabetical order using ‘ls’ and move them. A script for doing this is here: mvmp3.sh. Run it in the directory containing the artist folders and it will process all albums in each folder. It creates a temporary directory, moves the files there and deletes the original directory (backup your collection first!!!). Because it uses mv and not copy, the process only takes a couple of seconds for a few throusand tracks. What I do is copy the files onto the SD card and then run the script.

One other point, and this baffled me for a while, the above script does not work on a Linux ext3 filesystem. No matter what order you copy the tracks to a directory on ext3 the listing order does not change. I’m sure there’s a perfectly good explanation for this. Suffice to say that it works fine on a FAT filesystem, and that’s what most MP3 players use.

One thought on “Changing the Order of Music Files on an SD Card”

Comments are closed.