Run a random file

I have a collection of childrens' TV shows on a computer connected to the family TV. It's a good way to allow the children to watch some TV for a limited period of time without adverts. When one show finishes and they ask me to put another one, I often say "Okay, but you have to wait 20 minutes". Usually in that time they find something else to do and forget about the TV.

Picking what to put on can be a bother though - if I try to play them in order I forget which one I put on last, and if I try to pick one at random I'll invariably pick some more often than others. So I wrote run_random (binary). This program takes its arguments, expands wildcards and recurses directories to obtain a list of files and then picks one at random and calls ShellExecute() on it (which, if it's a video file, will play the video).

It's a handy little utility but it's also a good testcase for some path and directory handling routines I wrote for various other purposes.

One Response to “Run a random file”

  1. [...] won't run DOS programs so it needed a rewrite, and once I had completed the filesystem routines I mentioned before it was just as [...]

Leave a Reply