How to scramble a playlist ?

eric at eric at
Tue Jan 20 22:09:25 CET 2009

Here's a way to do it in python:

#!/usr/bin/env python
import sys, random
filename = sys.argv[1]
a = open(filename).read().strip().split("\n")
for i in a:
     print i

If you're not famililar with shell stuff:

Save that to a file like "scramble" and then do:
python scramble myfile

You can just type "scramble myfile" after you've done
    "chmod +x scramble"

Probably you want to redirect the list into a file:
python scramble myplaylist.txt > /tmp/shuffledplaylist.txt
or you can add python code to accept another argument for an  
outfilename and write the file -- with a check to make sure you're not  
overwriting an existing file (don't want you to overwrite your  
playlist on accident :)


More information about the community mailing list