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
- 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
- Shuffle the list with
sort -R
- 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.
Comments
Write a comment.