2025-10-29 16:19:12 +09:00
|
|
|
import os
|
|
|
|
|
import shutil
|
2026-04-08 16:07:00 +09:00
|
|
|
import glob
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
# ── 설정 ────────────────────────────────────────────────────────────────
|
2026-04-27 17:01:47 +09:00
|
|
|
exam_round = "2604" # 회차명
|
2026-04-08 16:07:00 +09:00
|
|
|
exam_code = "DIW" # 코드명
|
2025-12-30 16:59:36 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
source_dir = rf"D:\project\HWP\HWP-Scoring\회차별채점자료\{exam_round}"
|
|
|
|
|
output_base = r"input"
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
types = ["A", "B", "C", "D", "E"]
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
# ── 복사 실행 ────────────────────────────────────────────────────────────
|
|
|
|
|
for type in types:
|
2026-04-27 17:01:47 +09:00
|
|
|
pattern = os.path.join(source_dir, f"*{type}*")
|
2026-04-08 16:07:00 +09:00
|
|
|
matched = [d for d in glob.glob(pattern) if os.path.isdir(d)]
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
if not matched:
|
|
|
|
|
print(f"[WARN] 폴더 없음: {pattern}")
|
|
|
|
|
continue
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
src_folder = matched[0]
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
file_pattern = os.path.join(src_folder, f"제*회 디지털정보활용능력 워드프로세서(한글2022버전) {type}형 정답.hwpx")
|
|
|
|
|
matched_files = glob.glob(file_pattern)
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
if not matched_files:
|
|
|
|
|
print(f"[WARN] 파일 없음: {file_pattern}")
|
|
|
|
|
continue
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
src_path = matched_files[0]
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
# 원본 확장자 추출 후 새 파일명 생성: 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)
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
dst_path = os.path.join(dst_folder, new_filename)
|
|
|
|
|
shutil.copy2(src_path, dst_path)
|
|
|
|
|
print(f"[OK] {type}형 복사 완료 → {dst_path}")
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
# ── TEST 폴더 생성 ────────────────────────────────────────────────────────
|
|
|
|
|
test_folder = os.path.join(output_base, exam_round, type, "TEST")
|
|
|
|
|
os.makedirs(test_folder, exist_ok=True)
|
2025-10-29 16:19:12 +09:00
|
|
|
|
2026-04-08 16:07:00 +09:00
|
|
|
print("\n전체 처리 완료.")
|