Read Directory icon

Read Directory

Reads the contents of a local directory, but without importing the binary data of files into the workflow, as the native n8n node does

Overview

This node reads the contents of a specified local directory on the filesystem. Unlike some native nodes that import file binary data, this node only lists the directory entries without loading the actual file contents. It provides metadata about each entry such as its name and whether it is a file or a directory.

Common scenarios where this node is useful include:

  • Enumerating files and folders in a directory to process their names or attributes.
  • Creating workflows that branch based on directory structure.
  • Preparing lists of files for further processing without loading large file data into memory.

For example, you could use this node to list all files in a folder before filtering or moving them, or to generate a report of directory contents.

Properties

Name Meaning
Path The path of the directory on the local filesystem whose contents you want to read.
Destination Key The key in the output JSON where the directory listing will be stored (default: "contents").

Output

The node outputs an array of objects under the specified destination key (default "contents"). Each object represents an entry in the directory with the following fields:

  • name: The name of the file or directory entry.
  • isDirectory: Boolean indicating if the entry is a directory.
  • isFile: Boolean indicating if the entry is a file.

Example output JSON snippet:

{
  "contents": [
    {
      "name": "example.txt",
      "isDirectory": false,
      "isFile": true
    },
    {
      "name": "subfolder",
      "isDirectory": true,
      "isFile": false
    }
  ]
}

The node does not output any binary data.

Dependencies

  • Requires access to the local filesystem where n8n is running.
  • Uses Node.js built-in fs module to synchronously read directory contents.
  • No external API keys or services are required.

Troubleshooting

  • Common issues:

    • Providing an invalid or inaccessible directory path will cause an error.
    • Permissions issues may prevent reading certain directories.
  • Error messages:

    • Errors related to filesystem access (e.g., "ENOENT" for non-existent path) will be thrown.
    • If "Continue On Fail" is enabled, errors for individual items will be captured in the output with an error property.
  • Resolution tips:

    • Verify the directory path is correct and accessible by the n8n process.
    • Ensure proper permissions are set on the directory.
    • Use absolute paths to avoid ambiguity.
    • Enable "Continue On Fail" to handle errors gracefully in batch executions.

Links and References

Discussion