2025-02-14 00:47:21 +09:00
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import unicodedata
|
|
|
|
|
|
|
|
|
|
def copy_dic_subdirs(source_root, target_root_b, target_root_c):
|
|
|
|
|
for root, dirs, files in os.walk(source_root):
|
|
|
|
|
for dir_name in dirs:
|
|
|
|
|
|
|
|
|
|
parent_dir = os.path.basename(os.path.dirname(os.path.join(root, dir_name)))
|
|
|
|
|
target_root = None
|
|
|
|
|
parent_dir = unicodedata.normalize('NFC', parent_dir)
|
|
|
|
|
|
|
|
|
|
# 부모 디렉토리가 '2교시'인지, '3교시'인지 확인
|
|
|
|
|
if parent_dir == '1교시':
|
|
|
|
|
target_root = target_root_b
|
|
|
|
|
elif parent_dir == '2교시':
|
|
|
|
|
target_root = target_root_c
|
|
|
|
|
|
|
|
|
|
if target_root:
|
|
|
|
|
source_dic_path = os.path.join(root, dir_name)
|
|
|
|
|
target_dic_path = os.path.join(target_root, dir_name)
|
|
|
|
|
|
|
|
|
|
# DIC 하위 디렉토리와 파일 복사
|
|
|
|
|
shutil.copytree(source_dic_path, target_dic_path, dirs_exist_ok=True)
|
|
|
|
|
print(f"Copied {source_dic_path} to {target_dic_path}")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print(f"Skipping {dir_name} under {parent_dir}, as it doesn't match '2교시' or '3교시'.")
|
|
|
|
|
|
|
|
|
|
def copy_ent_files(source_root, target_root):
|
|
|
|
|
# 대상 디렉토리가 없으면 생성
|
|
|
|
|
os.makedirs(target_root, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
for root, dirs, files in os.walk(source_root):
|
|
|
|
|
for file in files:
|
|
|
|
|
if file.endswith('.ent'):
|
2025-07-18 17:01:52 +09:00
|
|
|
space_remove_file = file.replace(" ","")
|
|
|
|
|
|
2025-02-14 00:47:21 +09:00
|
|
|
source_file_path = os.path.join(root, file)
|
2025-07-18 17:01:52 +09:00
|
|
|
target_file_path = os.path.join(target_root, space_remove_file)
|
2025-02-14 00:47:21 +09:00
|
|
|
|
|
|
|
|
# 파일 복사
|
|
|
|
|
shutil.copy2(source_file_path, target_file_path)
|
|
|
|
|
print(f"Copied {source_file_path} to {target_file_path}")
|
|
|
|
|
|
|
|
|
|
# 사용법
|
2025-08-01 17:28:24 +09:00
|
|
|
source_directory = r"D:\project\data\CAT_제2507회 정기\채점의뢰" # 원본 디렉토리 경로
|
|
|
|
|
target_directory = r"./ent/2507_CAT_3_A"
|
2025-02-14 00:47:21 +09:00
|
|
|
target_directory_a = r"./output/A" # '1교시'의 타겟 경로
|
|
|
|
|
target_directory_b = r"./output/B" # '2교시'의 타겟 경로
|
|
|
|
|
target_directory_c = r"./output/C" # '3교시'의 타겟 경로
|
|
|
|
|
|
|
|
|
|
copy_ent_files(source_directory, target_directory)
|