新增:
解决了文件夹下嵌套文件时的移动问题。
优化了代码,降低了复杂度。每个文件地址获取后便进行识别、移动。
TODO:
增加交互性
使用正则表达式筛选更复杂的文件
import shutil
import os
import glob
def move_file(path,dst):
list_path = os.listdir(path)
target_site = dst
file_list = list()
for i in range(0, len(list_path)):
full_path = os.path.join(path, list_path[i])
if os.path.isdir(full_path):
file_list.extend(get_path(full_path,dst))
if os.path.isfile(full_path):
file_list.append(full_path)
temp_file = file_list[-1]
if temp_file[-3:] == 'png':
print("文件",temp_file,'符合条件')
print("目标文件",temp_file,"已经完成移动。\n")
return 'The process has done.'
move_file(r"D:\pic1",r"D:\pic2")