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

FileFolderExistsTool

Check if a file or folder exists.

Parameters

  • path (str): The path to the file or folder to be checked.

Returns

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

  • output (bool): True if exists, False if not.
  • exit_code (int): 0 if success, 1 if failure.

Usage

(Learn more about: FolderCreateTool)

import asyncio
from embedia.tools import FolderCreateTool, FileFolderExistsTool
 
folder_create = FolderCreateTool()
folder_exists = FileFolderExistsTool()
asyncio.run(folder_create(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:56:51.890247+00:00] [id: 140195716639440] [event: Tool Start]
Tool: FolderCreateTool
Args: ()
Kwargs: {'folder': 'temp'}
 
[time: 2023-10-03T15:56:51.890418+00:00] [id: 140195716639440] [event: Tool End]
Tool: FolderCreateTool
ExitCode: 0
Output:
None
 
[time: 2023-10-03T15:56:51.891257+00:00] [id: 140195704477008] [event: Tool Start]
Tool: FileFolderExistsTool
Args: ()
Kwargs: {'path': 'temp'}
 
[time: 2023-10-03T15:56:51.891316+00:00] [id: 140195704477008] [event: Tool End]
Tool: FileFolderExistsTool
ExitCode: 0
Output:
True
Does temp folder exist? True