Nodes/ComfyUI-TinyBee/Filter Existing Files
ComfyUI Node

Filter Existing Files

Resume a Batch Without Regenerating Everything

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
Filter Existing Files
    • filtered_files
    string_list
    source_substring
    dest_substring
    return_existingtrue

    You've run a 500-image batch, it died at image 327, and the thought of regenerating 327 images to get the last 173 makes you want to close the laptop. Filter Existing Files is the "skip the ones I already have" node. Feed it a list of candidate file paths and it returns only the ones that are (or aren't) already on disk - so your batch loop only generates what's actually missing. It's one of those nodes you don't appreciate until the first time you need it, and then you wonder how you lived without it.

    How it works

    • string_list - the list of paths you're checking (output of Get List From File slots in perfectly).
    • source_substring / dest_substring - an optional find-and-replace applied to each path before checking. This is how you check a different location than the one in your list - say your list holds source image paths and you want to check whether the corresponding render exists in an output folder.
    • return_existing (default on) - when on, keep only paths whose transformed name already exists on disk; when off, keep only the ones that don't exist. The off mode is the resume-batch mode: "give me everything still missing."

    The check itself is a glob: each item (after substring replacement) has its extension stripped, a * is appended, and the node looks for any matching file. So out/foo.png becomes out/foo*, which matches foo.png, foo.jpg, any extension - meaning "does anything with this base name exist?" That's usually exactly what you want when a batch run might have written a different format than the one you asked for.

    Two details worth knowing. First, the node only even considers items whose original path exists - items that don't exist on disk are skipped before any globbing happens, which is a quirk you'll bump into if your input list contains speculative paths. Second, return_existing inverts the match result, not the existence check: with it off, you get paths that exist but have no transformed-name matches.

    Where you'd actually use it

    • Resume interrupted batches: load the full intended output list, filter with return_existing off, feed the survivors into your generator.
    • Source → output mapping: list of source files, source_substring = source folder, dest_substring = output folder, and keep only the ones still unrendered.
    • Skipping already-processed items in a dataset prep or upscale pass.

    Installing it

    Standard pack install - part of ComfyUI-TinyBee under 🐝TinyBee/Lists:

    1. ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee" → Install, then restart ComfyUI.
    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Restart after cloning. No models, no real dependencies (pure os/glob), though the pack's requirements.txt nominally lists pillow and jsonata.

    Gotchas

    The two behaviors above are the traps: the original-path existence gate, and the fact that "existing" is decided by globbing a base name with any extension, not by an exact filename match. If your workflow genuinely needs exact-name matching, this node will surprise you - it's deliberately loose. Also remember the * is appended after stripping the extension from the transformed path, so if your dest_substring replacement produces a path that itself has directory parts, that works fine, but be sure the replacement produces something a glob can actually match. And because the node re-runs every execution, a file written a split second before the queue tick can race the check - rare, but real, in tight automation loops.

    Category🐝TinyBee/Lists

    Inputs (4)

    NameTypeDefaultDescription
    string_listSTRING
    source_substringSTRING
    dest_substringSTRING
    return_existingBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    filtered_filesSTRING