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

FileFolderMoveTool

Moves a file or a folder from one location to another. Can also be used to rename a file or folder.

Parameters

  • src (str): The path to the file or folder to be moved.
  • 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, FileFolderMoveTool, FileFolderExistsTool
 
folder_create = FolderCreateTool()
folder_move = FileFolderMoveTool()
folder_exists = FileFolderExistsTool()
asyncio.run(folder_create(folder="temp"))
asyncio.run(folder_move(src="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-04T03:38:10.839120+00:00] [id: 139688270564304] [event: Tool Start]
Tool: FolderCreateTool
Args: ()
Kwargs: {'folder': 'temp'}
 
[time: 2023-10-04T03:38:10.839537+00:00] [id: 139688270564304] [event: Tool End]
Tool: FolderCreateTool
ExitCode: 0
Output:
None
 
[time: 2023-10-04T03:38:10.841944+00:00] [id: 139688255673040] [event: Tool Start]
Tool: FileFolderMoveTool
Args: ()
Kwargs: {'src': 'temp', 'destination': 'temp2'}
 
[time: 2023-10-04T03:38:10.842482+00:00] [id: 139688255673040] [event: Tool End]
Tool: FileFolderMoveTool
ExitCode: 0
Output:
None
 
[time: 2023-10-04T03:38:10.843858+00:00] [id: 139688280942288] [event: Tool Start]
Tool: FileFolderExistsTool
Args: ()
Kwargs: {'path': 'temp2'}
 
[time: 2023-10-04T03:38:10.844018+00:00] [id: 139688280942288] [event: Tool End]
Tool: FileFolderExistsTool
ExitCode: 0
Output:
True
Does temp2 folder exist? True