Files
diw/01_copy_files_answer.py
2026-04-08 16:07:00 +09:00

49 lines
2.0 KiB
Python

import os
import shutil
import glob
# ── 설정 ────────────────────────────────────────────────────────────────
exam_round = "2603" # 회차명
exam_code = "DIW" # 코드명
source_dir = rf"D:\project\HWP\HWP-Scoring\회차별채점자료\{exam_round}"
output_base = r"input"
types = ["A", "B", "C", "D", "E"]
# ── 복사 실행 ────────────────────────────────────────────────────────────
for type in types:
pattern = os.path.join(source_dir, f"*회 {type}")
matched = [d for d in glob.glob(pattern) if os.path.isdir(d)]
if not matched:
print(f"[WARN] 폴더 없음: {pattern}")
continue
src_folder = matched[0]
file_pattern = os.path.join(src_folder, f"제*회 디지털정보활용능력 워드프로세서(한글2022버전) {type}형 정답.hwpx")
matched_files = glob.glob(file_pattern)
if not matched_files:
print(f"[WARN] 파일 없음: {file_pattern}")
continue
src_path = matched_files[0]
# 원본 확장자 추출 후 새 파일명 생성: DIW_2602A.hwpx
src_ext = os.path.splitext(src_path)[1]
new_filename = f"{exam_code}_{exam_round}{type}{src_ext}"
dst_folder = os.path.join(output_base, exam_round, type, exam_code)
os.makedirs(dst_folder, exist_ok=True)
dst_path = os.path.join(dst_folder, new_filename)
shutil.copy2(src_path, dst_path)
print(f"[OK] {type}형 복사 완료 → {dst_path}")
# ── TEST 폴더 생성 ────────────────────────────────────────────────────────
test_folder = os.path.join(output_base, exam_round, type, "TEST")
os.makedirs(test_folder, exist_ok=True)
print("\n전체 처리 완료.")