import os
import shutil
def copy_files(source_directory, destination_directory, file_extension):
copy_files_count = 0
for root, dirs, files in os.walk(source_directory):
for file in files:
if file.endswith(file_extension):
print(file)
source_file = os.path.join(root, file)
destination_file = os.path.join(destination_directory, file)
shutil.copy2(source_file, destination_file)
print('file:' + source_file + file)
copy_files_count = copy_files_count + 1
print('拷贝了',copy_files_count,'文件')
# 示例用法
source_directory = 'W:\\tf_v2.13.0\\tflite_build_x86\\'
destination_directory = 'W:\\tf_v2.13.0\\tf_static_lib_x86'
file_extension = '.lib'
copy_files(source_directory, destination_directory, file_extension)
source_directory = 'W:\\tf_v2.13.0\\tflite_build\\'
destination_directory = 'W:\\tf_v2.13.0\\tf_static_lib_x64'
file_extension = '.lib'
copy_files(source_directory, destination_directory, file_extension)
批量文件拷贝
最新推荐文章于 2024-11-12 23:15:59 发布