0

I want to create a random playlist for my entire music collection of 90,000 tracks. - i.e.generate a single m3u playlist containing every mp3 in every subfolder of my music folder, and present the list in random order. Any suggestions for how I can do that?

1 Answer 1

1

First, set up the list (you only need to do this when you add/delete files) :

find Music -type f -print >files.list
wc -l files.list >files.list.nlines

Then, to pick a random one,

line_number=$(echo "$(cat files.list.nlines) * $RANDOM / 32767" | bc -q)
file_to_play="$(sed -n ${line_number}p files.list)"
6
  • Thanks. The first command works well, but generates a list of all files - how would I adapt it to list just the mp3's? I can't get the 2nd command to work. When I run it I get a ">" prompt. Is there a syntax error? Feb 4, 2019 at 23:44
  • @user1175461 Fixed.
    – waltinator
    Feb 5, 2019 at 4:38
  • You can use the shuf command instead (shuf -o files.list files.list).
    – Olorin
    Feb 5, 2019 at 4:40
  • Thanks - wow that shuf command worked unfeasibly quickly! Feb 5, 2019 at 10:46
  • How can I adapt the first command to include only mp3 files? Feb 5, 2019 at 10:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .