File size: 1,084 Bytes
787163a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import re
import shutil

current_directory = os.getcwd()
# print(f'当前目录:{current_directory}')
# 定义你的.bat文件的原始路径
bat_file_path = os.path.join(current_directory, 'DeleteResults.exe')

# 定义目标目录路径
target_directory_path = current_directory

# 正则表达式来匹配 number-number 格式的文件夹
folder_name_pattern = re.compile(r"^\d+-\d+$")

# 遍历目标目录中的所有项
for folder_name in os.listdir(target_directory_path):
    # 构建完整的文件夹路径
    folder_path = os.path.join(target_directory_path, folder_name)
    # 检查这是一个目录且符合我们的命名规则
    # print(f'检查目录:{folder_path}')
    if os.path.isdir(folder_path) and folder_name_pattern.match(folder_name):
        # 构建目标.bat文件路径
        destination_bat_path = os.path.join(folder_path, os.path.basename(bat_file_path))
        # 复制.bat文件到目标文件夹
        shutil.copyfile(bat_file_path, destination_bat_path)
        print(f'复制到:{folder_path}')