Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have photos grouped by albums, with a different folder for each album. I would like to open a folder/album randomly to add variety when viewing photo albums. I already know of an image viewer than can shuffle the viewing order of images; I'm looking for a way to randomly open a folder within a directory to complement it.

The OS I am using is Windows 7.

share|improve this question
Open the directory in explorer? – invert Nov 12 '10 at 11:35
I've written a random music album chooser for this very reason. – ChrisF Nov 12 '10 at 13:04
@wez Yes, open a random folder/directory and show it using Windows Explorer. Or if there's an image viewer program that can open it within its own directory viewer, that would be fine too, although I prefer that it be opened with Explorer so I can choose which program to use to open the image files. – galacticninja Nov 13 '10 at 10:19
up vote 1 down vote accepted

This Python script will open a random directory, it takes the working directory to randomize as an argument. You can setup a shortcut to call this as well.

#!/usr/bin/env python
import os
import sys
import random
import subprocess
if __name__ == "__main__":
    if len(sys.argv) == 2:
        dirname = sys.argv[1]
        li = [f for f in os.listdir(dirname) if os.path.isdir(os.path.join(dirname, f))]
        random_dir = li[random.randint(0, len(li)) - 2]
        random_dir = os.path.join(dirname, random_dir)
        print('opening %s' % (random_dir))['explorer.exe', random_dir])
        print('Usage: python base-directory')

Usage: python "c:\photos"

share|improve this answer
Sir, could you point me to the installation instructions and software I need to install to be able to use this Python script? (I've never used one before.) – galacticninja Nov 13 '10 at 10:23
If you go to you can find great install instructions and the setup download too. Also look at you can view images randomly and open an image with external editor directly, and has a thumbnail browser. Might be what you need. – invert Nov 16 '10 at 6:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.