FileUtils icon

FileUtils

File system operations utility

Find Files

AI-generated

Overview

This node operation uses the system's find command to search for files and directories within a specified directory path. It supports filtering by file extensions, custom extensions, and regular expression patterns. Users can specify whether to show files, directories, or both, and can limit the search depth, sort results by various attributes, and exclude certain patterns. It is useful for scenarios where you need to locate specific files or directories based on criteria such as type, name, or location, for example, finding all image files in a project folder or locating all directories without subdirectories.

Use Case Examples

  1. Find all image files (.jpg, .png, etc.) in a directory and its subdirectories up to a certain depth.
  2. Search for all directories only, excluding those with subdirectories, sorted by modification time.
  3. Locate files with specific extensions and exclude certain patterns using regex filters.

Properties

Name Meaning
Directory Path The root directory path where the search will start. Required.
File Extensions Predefined file extension groups to filter the search results, such as images, documents, archives, videos, audio, and text files. Can be combined with custom extensions.
Custom File Extensions Additional comma-separated file extensions to include in the search, allowing for custom filtering beyond predefined groups.
Show Determines whether to show files, directories, or both in the search results.
Only Leaf Folders If enabled, only directories without subdirectories (leaf folders) are returned. Applicable when showing directories or both files and directories.
Max Depth Maximum directory depth to traverse during the search, ranging from 1 to 9.
Sort By Attribute by which to sort the search results, such as name, modified time, type, size, depth, full path, or parent directory.
Sort Direction Direction to sort the results, either ascending or descending.
Filter Pattern Regular expression pattern to include files or directories matching the pattern in the results.
Exclude Pattern Regular expression pattern to exclude files or directories matching the pattern from the results.
Maximum Records Limits the maximum number of records returned to avoid memory issues, with a range from 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 are found, an empty object is returned.

Output

JSON

  • datas - Array of found files and/or directories matching the search criteria when Return Single Object is true.
  • * - Individual file or directory objects returned as separate JSON items when Return Single Object is false.

Troubleshooting

  • Ensure the directory path is valid and accessible; an invalid or inaccessible path will cause errors.
  • File extension filters must be correctly formatted; custom extensions should be comma-separated without spaces.
  • Regular expression patterns for filter and exclude must be valid regex; invalid patterns will cause errors.
  • If Return Single Object is enabled but no results are found, the output will be an empty object, which might require handling downstream.

Discussion