file_agent = Agent( name="FileManager", role="File System Specialist", goal="Manage files and directories efficiently.", backstory="Expert in file system operations and organization.", tools=[read_file, write_file, list_files, get_file_info, copy_file, move_file, delete_file], self_reflect=False)
4
Define Task
Define the file management task:
Copy
file_task = Task( description="Organize files in the downloads directory by file type.", expected_output="Organized directory structure with categorized files.", agent=file_agent, name="organize_files")
# Basic usagesuccess = write_file("output.txt", "Hello World")# With specific encoding and nested pathsuccess = write_file( "path/to/data/output.txt", "Content with special chars: áéíóú", encoding="utf-8")# Returns: bool (True if successful)
# List and organize files by extensionfiles = list_files("downloads", pattern="*.*")for file in files: ext = file['extension'] if ext: dst = f"organized/{ext[1:]}/{file['name']}" move_file(file['path'], dst)