2603회 채점완료
This commit is contained in:
62
01_copy_files_by_answer.py
Normal file
62
01_copy_files_by_answer.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
# ── 설정 ────────────────────────────────────────────────────────────────
|
||||
exam_round = "2603"
|
||||
exam_codes = ["DIC", "DPI"]
|
||||
|
||||
base_dir = rf"D:\project\GOM\DIC\회차별채점자료"
|
||||
output_base = r"output"
|
||||
|
||||
types = ["A", "B", "C", "D", "E"]
|
||||
|
||||
# ── 복사 실행 ────────────────────────────────────────────────────────────
|
||||
for exam_code in exam_codes:
|
||||
for type in types:
|
||||
# 원본 형 폴더 탐색: "2603회 A형" 또는 "2603회 A형(클리핑)" 매칭
|
||||
type_pattern = os.path.join(
|
||||
base_dir, exam_round, exam_code,
|
||||
f"{exam_round}회 {type}형*"
|
||||
)
|
||||
matched_type_folders = [d for d in glob.glob(type_pattern) if os.path.isdir(d)]
|
||||
|
||||
if not matched_type_folders:
|
||||
print(f"[WARN] 형 폴더 없음: {type_pattern}")
|
||||
continue
|
||||
|
||||
type_folder = matched_type_folders[0]
|
||||
|
||||
# 하위 정답파일 폴더 탐색
|
||||
answer_dir = os.path.join(type_folder, "정답파일")
|
||||
if not os.path.isdir(answer_dir):
|
||||
print(f"[WARN] 정답파일 폴더 없음: {answer_dir}")
|
||||
continue
|
||||
|
||||
candidate_folders = [
|
||||
d for d in glob.glob(os.path.join(answer_dir, "*"))
|
||||
if os.path.isdir(d)
|
||||
]
|
||||
|
||||
if not candidate_folders:
|
||||
print(f"[WARN] 복사할 폴더 없음: {answer_dir}")
|
||||
continue
|
||||
|
||||
# 대상 경로: output\2603\A\DIC
|
||||
dst_base = os.path.join(output_base, exam_round, type, exam_code)
|
||||
os.makedirs(dst_base, exist_ok=True)
|
||||
|
||||
for src_folder in candidate_folders:
|
||||
folder_name = os.path.basename(src_folder)
|
||||
# 폴더명 뒤에 {type} 텍스트 추가: dpi_03_123456_성명A
|
||||
new_folder_name = f"{folder_name}{type}"
|
||||
dst_path = os.path.join(dst_base, new_folder_name)
|
||||
shutil.copytree(src_folder, dst_path, dirs_exist_ok=True)
|
||||
print(f"[OK] {exam_code} {type}형 복사 완료: {src_folder} → {dst_path}")
|
||||
|
||||
# TEST 폴더 생성: D:\project\GOM\DIC\output\2603\A\TEST
|
||||
test_folder = os.path.join(output_base, exam_round, type, "TEST")
|
||||
os.makedirs(test_folder, exist_ok=True)
|
||||
print(f"[OK] TEST 폴더 생성 완료 → {test_folder}")
|
||||
|
||||
print("\n전체 처리 완료.")
|
||||
Reference in New Issue
Block a user