randomising tracks: scripting question
xaero at xaerolimit.net
Sun Dec 26 20:07:27 UTC 2010
On Sun, Dec 26, 2010 at 2:04 PM, b. f. <bf1783 at googlemail.com> wrote:
> Frank Shute wrote:
> >I generally play my tracks of an album like so:
> >for track in $(cat trombone_shorty-backatown.m3u); do
> >mplayer $track
> >They then play in the correct order.
> >How would I go about randomising the order of play using
> >sh (preferably) or perl?
> cat trombone_shorty-backatown.m3u | xargs mplayer ... -shuffle
> mplayer ... -playlist trombone_shorty-backatown.m3u -shuffle
> if they are in a uncommented, one-absolute-path-per-line format
> without extended directives?
Here is something that I wrote a long time ago in python, works quite well
for i,j in enumerate(file(f, 'rb')):
if random.randint(0,i) == i:
line = j
Name it as you wish then it's ./file.py <INPUT>, granted this will only read
1 (random) line from INPUT and print it, it shouldn't be hard to modify this
for your needs tho, enjoy :)
More information about the freebsd-questions