copy_workbook
Copy spreadsheet files to new locations while preserving all data. Specify source and destination paths to create duplicate workbooks.
Instructions
Copy an existing spreadsheet file to a new location.
Performs a full file copy preserving all data. The destination must not already exist. Returns the absolute path of the new file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Path to the existing spreadsheet file to copy | |
| destination | Yes | Path for the new copy. Must not already exist. |
Implementation Reference
- The copy_workbook tool handler executes a file copy using shutil.copy2, validates that the source exists and the destination does not, and returns the absolute path of the new file.
def copy_workbook( source: Annotated[str, Field(description="Path to the existing spreadsheet file to copy")], destination: Annotated[str, Field(description="Path for the new copy. Must not already exist.")], ) -> str: """Copy an existing spreadsheet file to a new location. Performs a full file copy preserving all data. The destination must not already exist. Returns the absolute path of the new file. """ src = Path(source) if not src.exists(): raise ValueError(f"Source not found: {source}") dst = Path(destination) if dst.exists(): raise ValueError(f"Destination already exists: {destination}") shutil.copy2(src, dst) return str(dst.resolve())