coming soon

April 10, 2005 – 9:04 am

I'm working on a script randomly grab mp3s from a playlist and fill a CD with shuffled songs.

I'll be using bash's built-in random number generator which I believe is available in all versions.

Here's the shuffle function for those interested:


# Usage: shuffle <filename>
function shuffle () {

   cat "${@}"|grep -v "^#" | \
   while read mp3 ; do
      echo "$RANDOM $mp3"
   done | sort | cut -d" " -f2-
}

Requirements will be mpg321 and cdrecord.

  1. One Response to “coming soon”

  2. Great idea for the shuffle! The "sort" might or should be "sort -n", at least for consistency. BTW, I compared your shuffle() with a simple perl script using mainly "splice(@array, rand @array, 1)". The perl shuffles 40k lines in 0.5 seconds whereas your shuffle() takes 8.2 seconds on a 2.4 GHz Xeon. Of course, the difference is of less importance when the number of lines is lower.

    By rattus on Mar 3, 2007

Post a Comment