We use cookies on our website.
Docs
API Reference
Tools
FolderCopyTool

FolderCopyTool

Copies a folder from one location to another.

Parameters

  • folder (str): The path to the folder to be copied.
  • destination (str): The path to the destination.

Returns

The return value is of the type: ToolReturn (Learn more about: ToolReturn) with the following output and exit_code:

  • output (None): None.
  • exit_code (int): 0 if success, 1 if failure.

Usage

(Learn more about: FolderCreateTool, FileFolderExistsTool)

import asyncio
from embedia.tools import FolderCreateTool, FolderCopyTool, FileFolderExistsTool
 
folder_create = FolderCreateTool()
folder_copy = FolderCopyTool()
folder_exists = FileFolderExistsTool()
asyncio.run(folder_create(folder="temp"))
asyncio.run(folder_copy(folder="temp", destination="temp2"))
resp = asyncio.run(folder_exists(path="temp2"))
print("Does temp2 folder exist?", resp.output)

Running the above code prints the following:

[time: 2023-10-03T15:48:26.483236+00:00] [id: 139873237479824] [event: Tool Start]
Tool: FolderCreateTool
Args: ()
Kwargs: {'folder': 'temp'}
 
[time: 2023-10-03T15:48:26.483577+00:00] [id: 139873237479824] [event: Tool End]
Tool: FolderCreateTool
ExitCode: 0
Output:
None
 
[time: 2023-10-03T15:48:26.484374+00:00] [id: 139873213377360] [event: Tool Start]
Tool: FolderCopyTool
Args: ()
Kwargs: {'folder': 'temp', 'destination': 'temp2'}
 
[time: 2023-10-03T15:48:26.484686+00:00] [id: 139873213377360] [event: Tool End]
Tool: FolderCopyTool
ExitCode: 0
Output:
temp2
 
[time: 2023-10-03T15:48:26.485288+00:00] [id: 139873238279440] [event: Tool Start]
Tool: FileFolderExistsTool
Args: ()
Kwargs: {'path': 'temp2'}
 
[time: 2023-10-03T15:48:26.485344+00:00] [id: 139873238279440] [event: Tool End]
Tool: FileFolderExistsTool
ExitCode: 0
Output:
True
Does temp2 folder exist? True