Overview
The node provides various file system utility operations, including listing directory contents, finding files with specific criteria, reading file content, writing content to files, and searching for text patterns inside files. The "Find Files" operation specifically uses the system's find command to search for files and directories within a specified directory path, supporting filtering by file extensions, regex patterns, sorting, and limiting results.
This node is beneficial in automation workflows where you need to dynamically locate files or directories based on complex criteria, such as file type, name patterns, or directory depth. For example, it can be used to find all image files in a folder tree before processing them, or to locate log files matching certain naming conventions for analysis.
Properties
| Name | Meaning |
|---|---|
| Directory Path | The root directory path where the search will start. Required. |
| File Extensions | Select one or more predefined groups of file extensions to filter the search (e.g., Images, Documents, Archives, Videos, Audio, Text). Can be combined with custom extensions. |
| Custom File Extensions | Additional comma-separated file extensions to include in the search (e.g., .txt,.pdf,.doc). |
| Show | Choose whether to return files only, directories only, or both files and directories. |
| Only Leaf Folders | If enabled, only directories without any subdirectories (leaf folders) will be returned. Applies when showing directories or both files and directories. |
| Max Depth | Maximum directory depth to traverse during the search. Value between 1 and 9. |
| Sort By | Criteria to sort the results by: Name, Modified Time, Type, Size, Depth, Full Path, or Parent Directory. |
| Sort Direction | Sort order: Ascending or Descending. |
| Filter Pattern | Regular expression pattern to include only files/directories matching this pattern. |
| Exclude Pattern | Regular expression pattern to exclude files/directories matching this pattern from the results. |
| Maximum Records | Limit the maximum number of records returned to avoid excessive memory usage. Range: 1 to 5000. |
| Return Single Object | If enabled, returns a single object instead of an array. If multiple results are found, only the first is returned; if none found, returns an empty object. |
Output
The output consists of JSON objects representing each found file or directory matching the search criteria. Each JSON object contains metadata about the file or directory, such as its name, path, type, size, modification time, and depth in the directory tree.
If the "Return Single Object" property is enabled, the output is a single JSON object containing a datas field with either an array of results or a single result.
No binary data output is produced by this operation.
Dependencies
- The node relies on the underlying system's
findcommand or equivalent functionality to perform file searches. - No external API keys or services are required.
- Proper permissions to access the specified directories and files on the filesystem are necessary.
- No special environment variables or n8n configurations are needed beyond standard node setup.
Troubleshooting
Common Issues:
- Missing or incorrect directory path: The node requires a valid directory path to operate. Ensure the path exists and is accessible.
- Insufficient permissions: The node may fail if it lacks read permissions for the target directories or files.
- Invalid regular expressions in filter or exclude patterns can cause errors or unexpected results.
- Specifying incompatible combinations of options (e.g., requesting only leaf folders but also files only) may yield no results.
Error Messages:
"Directory path is required": Indicates the directory path parameter was not provided or empty."Unknown error occurred": Generic catch-all error; check node logs for details.- Errors related to invalid regex patterns: Verify the syntax of your filter or exclude patterns.
Resolution Tips:
- Double-check the directory path and ensure it exists.
- Test regex patterns separately to confirm correctness.
- Adjust max depth and max records to reasonable values to avoid performance issues.
- Enable "Continue On Fail" in the node settings to handle errors gracefully in workflows.
Links and References
- Linux find command manual — for understanding how file searching works under the hood.
- Regular Expressions Tutorial — for crafting filter and exclude patterns.
- Node.js fs module documentation — general info on filesystem operations in Node.js.