Nodes/RisuTools/Check File Name Prefix Exists
ComfyUI Node

Check File Name Prefix Exists

Does that file exist yet? The doorman node

By tiamatiramisu·Created about a year ago·Updated about a year ago· 5
Check File Name Prefix Exists
    • exists
    directoryabsolute-path
    prefix

    Check File Name Prefix Exists does exactly what the name promises: you give it a directory and a prefix, it gives you a true or false. Nothing more, nothing hidden. It ships in RisuTools, the small pack from TiamaTiramisu built for workflows that talk to RisuAI - an AI roleplay/chat frontend in the same family as SillyTavern - but you'll reach for it in any workflow where "did this already happen?" is a real question.

    The payoff is conditionality. ComfyUI's default graph runs every branch every time, which is fine until you want "only render this if the newest batch has landed" or "skip if this character's image is already done." That's where a BOOLEAN output earns its keep: feed exists into whatever switch or logic node you already use (rgthree's Any Switch, an If-else, an Impact Pack gate), and the workflow only walks the branch you actually need.

    How it works

    The mechanism is boring in the best way. The node lists the directory with os.listdir(), checks each filename against prefix with a plain startswith(), confirms it's a real file (not a subfolder), and returns True the moment one matches. Two details make it friendlier than it looks:

    • If the directory itself doesn't exist or isn't a directory, it returns False instead of crashing. That means a wrong path reads as "no files" rather than a red error box, which is arguably a feature - just don't mistake a bad path for an empty folder.
    • Its IS_CHANGED returns a fresh random value on every execution, so the node always re-runs and never serves you a stale cached answer. For a "check the filesystem right now" node, that's the correct behavior.

    The two inputs that matter

    • directory (required) - the absolute path to scan. The shipped default is the literal placeholder string "absolute-path"; replace it with a real path or this node does nothing useful.
    • prefix (optional, defaults to "") - leave it empty and the node answers "does this directory have any files?".

    That's the entire input surface. There's one output, exists (BOOLEAN).

    Where people get burned

    Prefix matching is a naive startswith, not a glob and not regex. A prefix of img matches image1.png, images_backup.png, and a file literally named img. Case matters on Linux and macOS. And because the path is matched as plain text, "IM" will not match image1.png. If you want a tighter check, make your prefix distinctive - img_2026-08- - rather than fighting the substring behavior. And remember the path is absolute: ComfyUI's own input/ folder shortcuts don't apply here.

    Installing it

    Install the whole pack once; all four RisuTools nodes come with it. Through ComfyUI Manager, search RisuTools and hit install. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TiamaTiramisu/risutools
    

    Restart ComfyUI and you're done. No model downloads, no heavy dependencies - requirements.txt is just pillow and numpy, both already in any ComfyUI environment. Fair warning that this is an early-stage pack (version 0.0.1, placeholder README), but the source is short and readable, which is exactly what you want in a pack that runs arbitrary Python in your ComfyUI process.

    CategoryRisuTools/File

    Inputs (2)

    NameTypeDefaultDescription
    directorySTRINGabsolute-path
    prefixoptSTRING

    Outputs (1)

    NameTypeDescription
    existsBOOLEAN