原创|Python|查找指定文件|复制到指定目录

import os
import os.path
from shutil import copy

for dirpath, dirnames, filenames in os.walk(r".\完成"):  #相对路径  
    for filename in filenames:
        if (os.path.splitext(filename)[1] == ".xlsx") and ('一键数据汇总' in os.path.splitext(filename)[0]) :
            filepath = os.path.join(dirpath, filename)
            print(filepath)
            copy(filepath, "./%s"%filename)  #复制到指定路径

你可能感兴趣的:(原创|Python|查找指定文件|复制到指定目录)