26 lines
944 B
Python
26 lines
944 B
Python
import os
|
|
import shutil
|
|
|
|
|
|
def combine_dirs(conf):
|
|
source_root = conf['data']['combine_scr_dir']
|
|
target_root = conf['data']['combine_dst_dir']
|
|
for roots, dir_names, files in os.walk(source_root):
|
|
for dir_name in dir_names:
|
|
source_dir = os.path.join(roots, dir_name)
|
|
target_dir = os.path.join(target_root, dir_name.split('_')[0])
|
|
if not os.path.exists(target_dir):
|
|
os.mkdir(target_dir)
|
|
for filename in os.listdir(source_dir):
|
|
print(filename)
|
|
source_file = os.sep.join([source_dir, filename])
|
|
target_file = os.sep.join([target_dir, filename])
|
|
shutil.copy(source_file, target_file)
|
|
# print(f"已复制目录 {source_dir} 到 {target_dir}")
|
|
|
|
|
|
# if __name__ == '__main__':
|
|
# source_root = r'scatter_mini'
|
|
# target_root = r'C:\Users\123\Desktop\scatter-1'
|
|
# # combine_dirs(conf)
|