from pathlib import Path
import shutil


def copy_script(file, exp_dir):
    """
    Copy experimental script to experiment directory, with appended suffix
    """
    # Append the experiment id to the name of the source file
    base = Path(file).name[:-3]  # Remove .py suffix
    exp_id = str(exp_dir).split(sep="_")[-1]
    copy_path = exp_dir / f"{base}_{exp_id}.py"

    # Copy the file
    shutil.copy(file, copy_path)

    return copy_path