import os.shutil
def search_file(path, result):
child_files=os.listdir(path)
for child in child_files:
child = os.path.join(path, child)
result.append(child)
if os.path.isdir(child):
search_file(child, result)
if __name__ == '__main__':
result = list()
input_dir = input("请输入待搜索的目录")
output_dir = input("请输入保存的文件目录")
search_file(input_dir , output_dir)
print(33)
for res in result:
print(os.path.isfile(res))
if os.path.isfile(res) and res.endswith(".txt"):
print("move %s" % res)
shutil.move(res, output_dir)