Nodes/ControlFlowUtils/πŸ“ Folder Search
ComfyUI Node

πŸ“ Folder Search

Feed Files Into ComfyUI One at a Time, Automatically

By VykosXΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 147
πŸ“ Folder Search
    • output
    β—„folder_path/β–Ί
    β—„search_mask*.*β–Ί
    β—„output_typefalseβ–Ί
    β—„recursivetrueβ–Ί
    β—„include_directoriesfalseβ–Ί
    β—„return_full_pathfalseβ–Ί
    β—„relative_filenamesfalseβ–Ί
    β—„save_output_toβ–Ί

    ComfyUI can generate images until the cows come home, but point it at a folder full of existing files and it shrugs. FolderSearch (πŸ“ Folder Search, from ControlFlowUtils) is the missing piece: it scans a directory, matches files against a pattern, and hands them to your workflow - either all at once, or one file per execution so a loop can chew through a folder like a queue.

    This is the node that turns "process every PNG in this folder" from a manual chore into a pipeline. Combined with this pack's Loop nodes, you get a real batch processor: search the folder, load each file, process, save, next.

    The inputs that matter

    • folder_path - directory to scan. Absolute, or relative to ComfyUI's root.
    • search_mask - the glob-style pattern. * matches anything, ? a single character, # a single digit, [a-z] a range, [!abc] excludes. Default *.*. Want only PNGs? *.png.
    • output_type - the big decision:
      • Full file list - returns every match as a list in one shot.
      • Current file (default) - returns one file per execution, advancing through the list until exhausted, then returns an empty string and resets. This is the mode that makes folder-processing loops work.
    • recursive - on by default: scan subfolders too.
    • include_directories - off by default; folders won't appear in results unless enabled.
    • return_full_path - return full paths, or just filenames.
    • relative_filenames - with full paths off, include the parent folder relative to the search directory.
    • save_output_to (optional) - write the found-file list to a log file for later processing.

    The single output is either the full list or the current file depending on output_type.

    How people use it

    The one-file-at-a-time mode is the star. Feed it into a loop: each iteration loads the next file, does your processing, saves the result, and closes the loop - FolderSearch hands you the following file on the next lap. That's a folder batch job with maybe four nodes. Full-list mode is for when you want to pass the whole set somewhere at once, like a "list these files in the UI" utility.

    Watch the mask syntax if something returns nothing. *.* on Linux/macOS matches files with a dot; for extension-only matching on every OS, patterns like *.png are the safe bet. And remember return_full_path defaults to off - downstream loaders often want the full path, so if files aren't loading, that toggle is the first thing to check. When output_type is "current file" and the list is exhausted, you get an empty string - make sure whatever consumes it can handle that (that's the loop's end-of-input signal).

    Install

    FolderSearch ships in VykosX/ControlFlowUtils:

    # ComfyUI Manager β†’ Install Custom Nodes β†’ search "ControlFlowUtils"
    # or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/VykosX/ControlFlowUtils
    

    Restart, find it under 🐺 VykosX-ControlFlowUtils, and pair it with a Loop Open/Close pair for your first folder-batch workflow. No dependencies, no model files - it's pure filesystem logic.

    Category🐺 VykosX-ControlFlowUtils

    Inputs (8)

    NameTypeDefaultDescription
    folder_pathSTRING/Folder to search for files within
    search_maskSTRING*.*Pattern to match the found files against
    output_typeBOOLEANfalseHow the output should be returned, ALL files or one file at a time
    recursiveBOOLEANtrueSpecifies whether subfolders should be scanned as well
    include_directoriesBOOLEANfalseSpecifies whether directories should be included in the results
    return_full_pathBOOLEANfalseSpecifies whether the full file path should be returned or only the file name and extension
    relative_filenamesBOOLEANfalseSpecifies whether the filenames should be return along with their parent folder, relative to the search directory, or only the filenames themselves.
    save_output_tooptSTRINGOptional output file to save a list of found files to

    Outputs (1)

    NameTypeDescription
    output*All files found or the current file, based on the Output_Type