Skip to main content

Read and Write Files with the FileAccess Tool

This page explains how to read and write text files and Office files using the FileAccess tool, as well as how to configure and use it.

What Is the FileAccess Tool?

The FileAccess tool is a tool for accessing files on a local machine or server. AI agents and workflows can read from and write to files and folders under a specified base directory.

What You Can Mainly Do

  • Read and write text files
  • Read Office files such as Word and Excel
  • Create folders and retrieve folder lists

Goal of This Guide

Configure the basic settings of the FileAccess tool so that AI agents and workflows can perform file operations.

Process Flow

  1. Configure the basic settings of the FileAccess tool (specify the base directory)
  2. Configure the FileAccess tool for an AI agent
  3. Use the FileAccess tool in a workflow

1. Basic Settings

  1. Add the tool.
    From the Tools tab, select [Create New] - [FileAccess].

  2. Set the base directory.
    Set the base directory from the [Settings] tab.

The base directory is the parent folder that serves as the starting point for file operations.
The FileAccess tool can operate only on items under this directory.

How to Choose a Base Directory

Set the scope with the minimum required permissions according to your use case, for example:

  • If you use it for a specific project: the folder for that project.
  • If you want to use it more generally: a path close to the root such as C:/.

2. Configure It for an AI Agent

By configuring the FileAccess tool for an AI agent, the AI agent can freely operate on folders and files under the base directory.

  1. From the [Agents] tab - [Create New], select [Empty Agent].

  2. In the tool settings, select and enable the FileAccess tool.

    Optimize Token Consumption

    Each enabled function of the FileAccess tool, such as reading and writing, consumes tokens.
    Leave any unused functions turned off.

After the configuration is complete, you can ask the AI agent to perform file operations.
For example, even without a system prompt, it can work from a request like the following alone.

Research the latest AI trends, summarize the findings, and output them as a Markdown file to {output folder path}

The AI agent will automatically handle the research, summarization, and file output.

3. Use It in a Workflow

The FileAccess tool can also be used within workflow steps.
Here, this guide uses a workflow that retrieves the contents of all files under a specified folder as an example.

Workflow Process Flow

  1. Retrieve the list of files under the specified folder
  2. Loop through the file list
  3. Retrieve the content of each file

Create a Workflow

  1. Open the workflow editor screen.

  2. Retrieve the list of directories under the specified folder.
    Drag and drop "Execute Tool" from the toolbox on the left and place it as the first step, then configure its properties.

    Property Settings

    Retrieve the list of directories under the specified folder and store it in target_folderpath_list.

    PropertyRequiredSetting ItemDetails
    TitleTitleUse an easy-to-understand name so you can identify it later.
    DescriptionWhat the step does
    Tool NameThe FileAccess tool you created
    Function Name"Get Directory List"This node retrieves the directory list.
    directoryPathExample: {{targetDir}}Specify the folder path to retrieve.
    includeSubdirectoriesFalseSpecify whether to include subfolders. They are not included in this example.
    maxResultsExample: 5000The maximum number of directories to retrieve.
    Result StorageExample: target_folderpath_listStore the execution result in any variable.
  3. Configure loop processing to retrieve the folders stored in each directory.
    Drag and drop "Loop" and configure its properties.

    Property Settings

    Retrieve each folder one by one from the directory list (target_folderpath_list) obtained in the previous step.
    (The process in the following steps is repeated for each folder.)

    PropertyRequiredSetting ItemDetails
    TitleTitleUse an easy-to-understand name so you can identify it later.
    DescriptionWhat the step does
    Iteration Target{{target_folderpath_list}}Pass the list data to be looped over. (Output of step 2)
    Item Variabletarget_folderThe name used in the looped process. (Used in the next step)
    Maximum RunsExample: 5If the count is large, it takes time. During debugging, specify 2 to 5 runs.
  4. Retrieve the list of files in the folder.
    Drag and drop "Execute Tool" into the child element of the loop and configure its properties.

    Property Settings

    Retrieve the list of files.

    PropertyRequiredSetting ItemDetails
    TitleTitleUse an easy-to-understand name so you can identify it later.
    DescriptionWhat the step does
    Tool NameThe FileAccess tool you created
    Function Name"Get File List"This node retrieves the file list.
    directoryPathExample: {{target_folder}}Specify the folder path to retrieve.
    includeSubdirectoriesFalseSpecify whether to include subfolders. They are not included in this example.
    filePatternExample: *.txt or blankSpecify the extension pattern of the files to retrieve.
    Result StorageExample: target_file_listStore the execution result in a variable.
  5. Configure loop processing to retrieve file contents.
    Drag and drop "Execute Tool" into the child element of the loop and configure its properties.

    Property Settings

    Retrieve each file one by one from the file list (target_file_list) obtained in the previous step.
    (The process in the following steps is repeated for each file.)

    PropertyRequiredSetting ItemDetails
    TitleTitleUse an easy-to-understand name so you can identify it later.
    DescriptionWhat the step does
    Iteration TargetExample: {{target_file_list}}Pass the list data to be looped over. (Output of step 4)
    Item VariableExample: target_fileThe name used in the looped process. (Used in the next step)
    Maximum RunsExample: 5000If the count is large, it takes time. During debugging, specify 2 to 5 runs.
  6. Retrieve the file content.
    Drag and drop "Execute Tool" as a child element of the loop and configure its properties.

    Property Settings

    Retrieve the content of the target file.

    PropertyRequiredSetting ItemDetails
    TitleTitleUse an easy-to-understand name so you can identify it later.
    DescriptionWhat the step does
    Tool NameThe FileAccess tool you created
    Function Name"Get File Content"This node retrieves the content of the file.
    PathExample: {{target_file}}Select the item variable set in step 5.
    Result StorageExample: contentStore the execution result in a variable.

You have now retrieved the contents of the files under the specified folder.

Retrieve Subdirectories Recursively in One Operation

If you set includeSubdirectories in step 2 to true, you can retrieve all directories including subdirectories at once.
In that case, the loops in steps 3 to 5 are no longer necessary.
However, if there are many folders, be careful about processing time and the maxResults limit.

Check the Execution Results

After the workflow execution is complete, check the result of each step from the execution history.

  • Output of step 4: Confirm that the list of file paths has been retrieved correctly.
  • Output of step 6: Confirm that the content of each file has been retrieved correctly.
The retrieved file contents can be used in various later steps, such as passing them to an AI agent.

For examples of how to use them in workflows, also refer to "Create a Workflow for Comprehensive Review".

Additional Notes

Notes About the Base Directory

The FileAccess tool can operate only on files and folders under the specified base directory.

  • An error occurs if you specify a path outside the base directory.
  • Make sure in advance that the target files and folders exist under the base directory.

Using Multiple Tools Depending on the Purpose

If the purpose or base directory differs, you can create multiple FileAccess tools and use them separately.
Set each tool name appropriately so its purpose is clear.