import os def list_files(dir): r = [] for root, dirs, files in os.walk(dir): for name in files: r.append(os.path.join(root, name)) return r