import os
import shutil

# Define paths
source_folder = r"COPY FOLDER PATH HERE"
destination_folder = os.path.join(source_folder, "html")

# Create the subfolder if it doesn't exist
os.makedirs(destination_folder, exist_ok=True)

# Loop through files in the source folder
for filename in os.listdir(source_folder):
    if filename.lower().endswith(".txt"):
        base_name = os.path.splitext(filename)[0]
        new_filename = base_name + ".html"
        
        # Full paths
        source_path = os.path.join(source_folder, filename)
        destination_path = os.path.join(destination_folder, new_filename)

        # Rename and move
        shutil.move(source_path, destination_path)
        print(f"Moved and renamed: {filename} → html/{new_filename}")
