files = [os.path.join(path, filename) for path, dirs, files in os.walk(dir) for
    filename in files if not filename.endswith('.bak')]
Randomly selecting a file from a tree of directories in a completely fair manner