# -*- coding: utf-8 -*- import os def file_name(file_dir): with open("SelectAllFiles.txt","w") as f: for root, dirs, files in os.walk(file_dir,topdown=True): for name in files: f.write(name+' ') if __name__=="__main__": file_name(os.getcwd())