Nodes/GENKAI Nodes/Folder Search (genkai)
ComfyUI Node

Folder Search (genkai)

Walk a folder of clips, one file per run

By GENKAIx·Created about a month ago·Updated 21 days ago· 9
Folder Search (genkai)
    • output
    ◄folder_path/►
    ◄search_mask*.*►
    ◄output_typefalse►
    ◄recursivetrue►
    ◄include_directoriesfalse►
    ◄return_full_pathfalse►
    ◄relative_filenamesfalse►
    ◄infinite_loopfalse►
    ◄save_output_to►

    You have 400 PNGs in a folder and you want ComfyUI to chew through them without loading all 400 into VRAM at once. Or 60 mp4s to run past an upscaler. Folder Search is the node that hands you one path per execution so the rest of the graph never knows how many files there are.

    It's the plainest node in this pack: scan a directory with a glob mask, return either the whole list or the next single path. No models, no downloads, no cleverness.

    How it works

    Under the hood it's os.scandir plus fnmatch, recursing into subfolders when you ask it to. Two consequences you should know before you build anything on it:

    • Results come out in filesystem traversal order. There is no sorting. If you want alphabetically ordered frames, sort downstream (or rename the files). On some filesystems the order changes between runs, which is a fun surprise when you're trying to make output reproducible.
    • It's an output node, so it always runs. That's what makes single-file mode advance: each time the graph executes, the node re-executes and yields the next path. Without infinite_loop it returns an empty string after the last file, and the next execution starts a new pass from the top. The node does not queue runs by itself - you still need something (a manager/requeue mechanism, or a loop extension) driving repeated executions.

    The inputs that matter

    folder_path is an absolute path on the machine running ComfyUI, and the default is /. On Windows that gets you nowhere useful, so set it first. search_mask is a glob - *.mp4, *.png, *.*. Note the default *.* will skip files with no extension, which is rarely what you want for a media folder.

    output_type is the one that trips people, because it's a boolean, not a dropdown. It shows as Full file list (true) or Current file (false). Read the labels, not the on/off state, or you'll wire up "one at a time" and wonder why you got a list.

    Then: recursive (default on - scanning C:\ with it on is a way to spend your afternoon), return_full_path for absolute paths, relative_filenames for paths relative to the search directory, include_directories if you want folders in the results too, and infinite_loop to wrap back to the first file instead of returning empty. The optional save_output_to writes the found paths to a text file, which is genuinely handy as a manifest you can diff between runs.

    The single output is the wildcard type, so you wire it into anything that takes a string. The usual move: right-click the image field on Load Image (or the video path field on VHS's Load Video) → Convert widget to input, then feed the path in. Keep a text-preview node on the wire while you're debugging; staring at a wire that carries an invisible string is miserable.

    For the list mode, the output is a list of paths, so it's only useful where the downstream node actually accepts a list. The one-at-a-time mode is the one you'll use most.

    How to install it

    ComfyUI Manager → search the pack title Genkai-ComfyUI-Nodes, or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GENKAIx/Genkai-ComfyUI-Nodes
    

    Restart ComfyUI, then Ctrl+F5 in the browser. Folder Search lives directly under the GENKAI nodes category (not GENKAI/Media or GENKAI/Video). No models, no extra pip packages - this file imports nothing beyond fnmatch and os.

    Two pack-level notes: it wants a reasonably current ComfyUI (the pack as a whole assumes VIDEO support and comfy_api.latest), and if you have an old install sitting in custom_nodes/GENKAI_nodes, delete it - two active copies register the same node identifiers and things get weird.

    Common issues

    Empty output and a loader erroring with "invalid image". Your mask matched nothing. *.jpg on a folder of .jpeg files does exactly this.

    The same file processes forever. infinite_loop is on. It's exactly what the label says: after the last result it goes back to the first.

    Paths that work locally but not for a shared workflow. Use return_full_path if the consumer needs to hit the filesystem directly; relative paths are resolved against your search directory, so a workflow shared with someone on a different machine breaks either way. The paths are local to whoever is running ComfyUI.

    CategoryGENKAI nodes

    Inputs (9)

    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_filenamesBOOLEANfalseReturn filenames with their parent folder relative to the search directory
    infinite_loopBOOLEANfalseAfter the last result, continue again from the first result
    save_output_tooptSTRINGOptional output file to save found files to

    Outputs (1)

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