규칙 적용 재추적
This commit is contained in:
35
post/filter.py
Normal file
35
post/filter.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# filter.py
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# 경로 설정
|
||||
DATA_ORIGIN_DIR = Path("data_origin")
|
||||
DATA_DIR = Path("data")
|
||||
DATA_JSON_DIR = Path("data_json")
|
||||
|
||||
|
||||
def main():
|
||||
# data_json 폴더 없으면 생성
|
||||
DATA_JSON_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# data_origin의 파일명(확장자 제외) 집합 생성
|
||||
origin_names = {f.stem for f in DATA_ORIGIN_DIR.iterdir() if f.is_file()}
|
||||
print(f"[INFO] data_origin 파일명(확장자 제외) 개수: {len(origin_names)}")
|
||||
|
||||
moved_count = 0
|
||||
|
||||
# data 폴더 순회
|
||||
for file_path in DATA_DIR.iterdir():
|
||||
if not file_path.is_file():
|
||||
continue
|
||||
if file_path.stem in origin_names:
|
||||
target_path = DATA_JSON_DIR / file_path.name
|
||||
shutil.move(str(file_path), target_path)
|
||||
moved_count += 1
|
||||
print(f"[MOVE] {file_path.name} -> {target_path}")
|
||||
|
||||
print(f"[DONE] 이동된 파일 수: {moved_count}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user