2025-08-29 18:22:31 +09:00
|
|
|
# 분류되지 않은 답안파일 원본 폴더에서 복사할 때 사용
|
2026-03-06 17:41:13 +09:00
|
|
|
# DIW 폴더가 있는 경우, 부모 디렉토리 이름에 따라 A, B, C, D, E 폴더로 복사
|
|
|
|
|
# 예시: D:\project\data\제2601회 정기\제2601회 정기\과목별답안파일\1교시\DIW → .\input\2601\A\DIW
|
2025-08-29 18:22:31 +09:00
|
|
|
|
2025-02-03 16:26:02 +09:00
|
|
|
import os
|
|
|
|
|
import shutil
|
2025-02-25 17:28:25 +09:00
|
|
|
import unicodedata
|
2025-02-03 16:26:02 +09:00
|
|
|
|
2025-02-25 17:28:25 +09:00
|
|
|
def copy_dic_subdirs(source_root, target_root_a, target_root_b, target_root_c, target_root_d, target_root_e):
|
|
|
|
|
for root, dirs, files in os.walk(source_root):
|
|
|
|
|
for dir_name in dirs:
|
2025-05-26 17:46:45 +09:00
|
|
|
if dir_name.lower() == 'diw': # DIW 디렉토리 탐색
|
2025-02-25 17:28:25 +09:00
|
|
|
parent_dir = os.path.basename(os.path.dirname(os.path.join(root, dir_name)))
|
|
|
|
|
target_root = None
|
|
|
|
|
parent_dir = unicodedata.normalize('NFC', parent_dir)
|
2025-02-03 16:26:02 +09:00
|
|
|
|
2025-02-25 17:28:25 +09:00
|
|
|
# 부모 디렉토리가 '2교시'인지, '3교시'인지 확인
|
|
|
|
|
if parent_dir == '1교시':
|
|
|
|
|
target_root = target_root_a
|
|
|
|
|
elif parent_dir == '2교시':
|
|
|
|
|
target_root = target_root_b
|
|
|
|
|
elif parent_dir == '3교시':
|
|
|
|
|
target_root = target_root_c
|
|
|
|
|
elif parent_dir == '4교시':
|
|
|
|
|
target_root = target_root_d
|
|
|
|
|
elif parent_dir == '5교시':
|
|
|
|
|
target_root = target_root_e
|
|
|
|
|
|
|
|
|
|
if target_root:
|
|
|
|
|
source_dic_path = os.path.join(root, dir_name)
|
2025-04-28 16:30:46 +09:00
|
|
|
target_dir_name = dir_name.upper()
|
|
|
|
|
target_dic_path = os.path.join(target_root, target_dir_name)
|
2025-02-03 16:26:02 +09:00
|
|
|
|
2025-02-25 17:28:25 +09:00
|
|
|
# DIC 하위 디렉토리와 파일 복사
|
|
|
|
|
shutil.copytree(source_dic_path, target_dic_path, dirs_exist_ok=True)
|
|
|
|
|
print(f"Copied {source_dic_path} to {target_dic_path}")
|
2025-05-07 02:36:04 +09:00
|
|
|
|
|
|
|
|
test_folder_path = os.path.join(target_root, "TEST")
|
|
|
|
|
os.makedirs(test_folder_path, exist_ok=True)
|
2025-05-26 17:46:45 +09:00
|
|
|
|
2025-05-07 15:45:24 +09:00
|
|
|
|
2025-02-25 17:28:25 +09:00
|
|
|
else:
|
|
|
|
|
print(f"Skipping {dir_name} under {parent_dir}, as it doesn't match '2교시' or '3교시'.")
|
|
|
|
|
|
|
|
|
|
# 사용법
|
2026-02-11 16:06:09 +09:00
|
|
|
exam_round = "2601"
|
2025-10-29 16:19:12 +09:00
|
|
|
# exam_round = "2510_4"
|
|
|
|
|
# source_directory = r"D:\project\data\제2510회 수시2(제주)\답안파일\제2510회 수시2 제주지부_답안파일"
|
2026-02-11 16:06:09 +09:00
|
|
|
source_directory = r"D:\project\data\제2601회 정기\제2601회 정기\과목별답안파일"
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2025-04-28 16:30:46 +09:00
|
|
|
|
|
|
|
|
target_directory_a = f".\\input\\{exam_round}\\A" # '1교시'의 타겟 경로
|
|
|
|
|
target_directory_b = f".\\input\\{exam_round}\\B" # '2교시'의 타겟 경로
|
|
|
|
|
target_directory_c = f".\\input\\{exam_round}\\C" # '3교시'의 타겟 경로
|
|
|
|
|
target_directory_d = f".\\input\\{exam_round}\\D" # '4교시'의 타겟 경로
|
|
|
|
|
target_directory_e = f".\\input\\{exam_round}\\E" # '5교시'의 타겟 경로
|
2025-02-03 16:26:02 +09:00
|
|
|
|
2025-02-25 17:28:25 +09:00
|
|
|
copy_dic_subdirs(source_directory, target_directory_a, target_directory_b, target_directory_c, target_directory_d, target_directory_e)
|
2025-08-29 18:22:31 +09:00
|
|
|
|