Python, Automation, Data Science, Artificial Intelligence, Llm.
exist subfolder_path = os.path.join(main_folder, subfolder) os.makedirs(subfolder_path, exist_ok=True) # Move the file to the appropriate subfolder destination_path = os.path.join(subfolder_path, filename) shutil.move(file_path, destination_path) print(f"Moved {filename} to {subfolder} folder.")