Overview
This node reads the contents of a specified local directory on the filesystem. It is useful when you need to list files and subdirectories within a folder as part of an automation workflow. For example, you might use it to retrieve all filenames in a directory before processing or filtering them further, or to monitor changes in a folder by periodically reading its contents.
Properties
Name | Meaning |
---|---|
Path | Path of a directory on the local filesystem whose contents you want to read. |
Output
The node outputs an array of objects under the json
field for each input item. Each object represents an entry (file or directory) inside the specified path with the following structure:
name
: The name of the file or directory.isDirectory
: Boolean indicating if the entry is a directory.isFile
: Boolean indicating if the entry is a file.
Example output JSON snippet:
{
"readdir": [
{
"name": "example.txt",
"isDirectory": false,
"isFile": true
},
{
"name": "subfolder",
"isDirectory": true,
"isFile": false
}
]
}
No binary data is output by this node.
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 needed.
Troubleshooting
- Common issues:
- Providing an invalid or inaccessible path will cause an error.
- Permissions issues may prevent reading certain directories.
- Error messages:
- Errors thrown by the underlying filesystem call (e.g., "ENOENT" for non-existent path).
- If "Continue On Fail" is enabled, errors for individual items will be included in the output with an
error
property.
- Resolution:
- Verify the directory path exists and is accessible by the user running n8n.
- Ensure correct permissions are set on the target directory.
- Use absolute paths to avoid ambiguity.