import os
import subprocess
from datetime import datetime

SOURCE = r"C:\Temp"
DESTINATION = r"Z:\Temp\projectAlpha\20261106"

# Create destination folder if needed
os.makedirs(DESTINATION, exist_ok=True)

timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
log_file = os.path.join(
    DESTINATION,
    f"robocopy_dryrun_{timestamp}.log"
)

cmd = [
    "robocopy",
    SOURCE,
    DESTINATION,
    "/E",      # Include subdirectories including empty
    "/L",      # List only - no copy
    "/FP",     # Full path names
    "/TS",     # Include timestamps
    "/TEE",    # Console + log output
    f"/LOG:{log_file}"
]

print("=" * 80)
print("ROBOCOPY DRY RUN")
print("=" * 80)
print(f"Source      : {SOURCE}")
print(f"Destination : {DESTINATION}")
print(f"Log File    : {log_file}")
print()

print("Executing:")
print(" ".join(cmd))
print()

result = subprocess.run(cmd)

print()
print("=" * 80)
print("COMPLETE")
print("=" * 80)
print(f"Robocopy Exit Code: {result.returncode}")
print(f"Log File          : {log_file}")

if result.returncode >= 8:
    print("WARNING: Robocopy reported one or more failures.")
else:
    print("Dry run completed successfully.")