#!/usr/bin/python # randomly shuffle arguments and pass them to another program. # # the first argument is treated as the name of a program to execute # with the shuffled arguments. # example # # cd ~/music/the-perishers/let-there-be-morning # shuffle mpg123 *.mp3 # # plays all mp3 files in current directory in random order, using the mpeg audio # player mpg123. (this example assumes your shell performs filename globbing, # which good shells do.) import random import sys import os random.seed() args = sys.argv[2:] random.shuffle(args) os.execvp(sys.argv[1], [sys.argv[1]] + args)