
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
아래 코드 진행 시 파일이 안나뉩니다..
import os
import shutil
base_path =r'C:\Users\Chloe\OneDrive\바탕 화면\python automation\move_folder'
file_list = os.listdir(base_path)
for file in file_list:
parts = file.split('_')
if len(parts) == 4:
job, career, name, age = parts
job_path = os.path.join(base_path, job)
career_path = os.path.join(job_path, career)
if not os.path.exists(job_path):
os.mkdir(job_path)
if not os.path.exists(career_path):
os.mkdir(career_path)
origianl_path = os.path.join(base_path, file)
new_path = os.path.join(career_path, file)
shutil.move(origianl_path, new_path)
print(file+ ' 의 파일 이동이 완료되었습니다.')
