The radio in my car has the strange habit of ordering the mp3 files on my USB stick by the timestamp of the files. This can give very unpredictable results, many albums play back in a seemingly random order. It would of course be much more logical if the radio would follow the track order given in the ID3 tags, or even simply order the files alphabetically as the filenames are often prefixed with the track numbers. I wonder at the logic behind this design decision.

I made a small BASH script that updates the timestamps in alphabetical order. This fixes the playback order.

#!/bin/bash
# This script updates the timestamps of all mp3 files in the current directory and all 
# subdirectories in alphabetical order. It waits one second between every update.
#
# It also saves a list of all found mp3 files in the text file 'mp3-index.txt'

find | grep mp3 | sort > mp3-index.txt

cat mp3-index.txt | while read line;
do
        echo "touching file $line"
        touch "$line"
        sleep 1
done
Share this
Tags:

    Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
    • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
    • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
    • Lines and paragraphs break automatically.

    More information about formatting options

    CAPTCHA
    This question is for testing whether you are a human visitor and to prevent automated spam submissions.