Shuffling movies with mplayer and bash

Suppose you have a bunch of movies in a directory and want to play them randomly; switch into that directory and run:

$ find -print0 | sort -zR | xargs -0 mplayer
  1. Generate a list of files in this directory and it's subdirectories; the list is zero terminated because I have some special characters in my filenames
  2. Shuffle the list with sort -R
  3. Pass each line as an argument to mplayer

The zero-termination of the list is accomplished with find -print0, sort -z and xargs -0.

You can of course alter the find command: For instance use find -maxdepth 1 to skip subdirectories.

Date:
Thu Aug 2013 20:20 UTC
Category:
Tags:

Comments

Write a comment.