import os
import shutil

destination_directory = "/home/seo2024.ir"

os.makedirs(destination_directory, exist_ok=True)

input_file = "linkss.txt"

output_file = os.path.join(destination_directory, "links.txt")

if os.path.exists(output_file):
    os.remove(output_file)

try:
    with open(input_file, "r", encoding="utf-8") as f_in:
        content = f_in.read()

    with open(output_file, "w", encoding="utf-8") as f_out:
        f_out.write(content)

    print(f"✅ File successfully saved to {output_file}")

except FileNotFoundError:
    print(f"❌ Error: The file {input_file} was not found. Make sure it exists in the correct folder.")
except PermissionError:
    print(f"❌ Error: No permission to write to {destination_directory}.")
except Exception as e:
    print(f"❌ Unexpected error: {e}")
