rand


Download rand
An Open Source command line random file utility

Random file generator

Program to execute on the command line to return a random file from a given directory

Usage:
rand [options] [path]

Options:
-d Directories as well as files.
-dir Just directories, no files.
-f Just files, this is by default
-q Outputs random file path inside "quotes" without a newline instead of outputing result on a new line. Very useful when pipiing into xargs or other command line utils
-r Recursive through directories in given path (not sure if links are followed...)
-regex Takes a regular expression pattern as an argument using perl syntax

Examples:
Find a random file not starting with '.'
./rand.pl -regex "^[^\.]"

Find and play a movie from a recursive search through a directory with mplayer
./rand.pl -regex "\.mp4|\.avi|\.mpg|\.mpeg|\.wmv|\.mkv|\.divx|\.mov|\.rmvb" /path/ | xargs -p mplayer