def oldest_file_in_tree(rootfolder, extension='.avi'):
    return min((os.path.join(dirname, filename) for dirname, dirnames,
        filenames in os.walk(rootfolder) for filename in filenames if
        filename.endswith(extension)), key=lambda fn: os.stat(fn).st_mtime)
Find the oldest file (recursively) in a directory