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

FolderDeleteTool

Deletes the requested folder and its contents, ignores if it doesn't exist. Asks for confirmation before deleting.

Parameters

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

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, FolderDeleteTool, FileFolderExistsTool
 
folder_create = FolderCreateTool()
folder_del = FolderDeleteTool()
folder_exists = FileFolderExistsTool()
asyncio.run(folder_create(folder="temp"))
asyncio.run(folder_del(folder="temp"))
resp = asyncio.run(folder_exists(path="temp"))
print("Does temp folder exist?", resp.output)

Running the above code prints the following:

[time: 2023-10-03T15:39:35.019607+00:00] [id: 139819567067280] [event: Tool Start]
Tool: FolderCreateTool
Args: ()
Kwargs: {'folder': 'temp'}
 
[time: 2023-10-03T15:39:35.020170+00:00] [id: 139819567067280] [event: Tool End]
Tool: FolderCreateTool
ExitCode: 0
Output:
None
 
[time: 2023-10-03T15:39:35.021169+00:00] [id: 139819542598736] [event: Tool Start]
Tool: FolderDeleteTool
Args: ()
Kwargs: {'folder': 'temp'}
 
Tool: FolderDeleteTool
Details: {'folder_name': 'temp', 'contents': []} Confirm (y/n): y
 
[time: 2023-10-03T15:39:38.325156+00:00] [id: 139819542598736] [event: Tool End]
Tool: FolderDeleteTool
ExitCode: 0
Output:
None
 
[time: 2023-10-03T15:39:38.326112+00:00] [id: 139819545669520] [event: Tool Start]
Tool: FileFolderExistsTool
Args: ()
Kwargs: {'path': 'temp'}
 
[time: 2023-10-03T15:39:38.326178+00:00] [id: 139819545669520] [event: Tool End]
Tool: FileFolderExistsTool
ExitCode: 0
Output:
False
Does temp folder exist? False