Nodes/Allergic Pack/Folder File Counter (Allergic)
ComfyUI Node

Folder File Counter (Allergic)

How many files are in that folder, right now, without running the queue

By usrname0·Created about a year ago·Updated 5 months ago· 2
Folder File Counter (Allergic)
    • folder_path_out
    • file_count
    folder_path

    You know the little stall where you're building a batch workflow and you just want to know how many images are sitting in that folder - so you can set a batch count, a filename counter, a "stop when I'm out of files" check? This is that, as a node. Type a folder path, get an INT out. That's the whole job, and it does it without making you run the graph to find out.

    Folder File Counter is one of four utility nodes in the Allergic Pack, the personal collection from usrname0 (who posts on r/comfyui as AllergicToTeeth) built for his own batch jobs and then released "for a stress test or a public flogging," as he put it. It's a plumbing node in the purest sense - no pixels touch it, it just hands other nodes a number.

    How it works

    The mechanism is refreshingly honest. You give it a folder path, it counts the regular files inside, and returns the count plus the cleaned-up path. Two details are worth knowing:

    • The path gets sanitized first. The pack's shared sanitize_path utility strips filesystem-unfriendly characters, collapses duplicate slashes, preserves Windows drive letters, and trims trailing dots and spaces. So if you paste a path with stray quotes or control characters from somewhere, the node cleans it rather than failing.
    • It counts files, not subdirectories. Only entries where os.path.isfile() is true. And if the folder doesn't exist or isn't readable, you get 0 - silently. That silent zero is the one trap here; a typo'd path looks like "this folder is empty" instead of "this folder path is wrong."

    There's a Get File Count button on the node that calls the pack's local API endpoint and updates the display without touching the queue, and a Select All Text button that just selects your path for easy copying. When the node runs for real, it renames the file_count output slot to show the actual number (e.g. file_count: 42), which is the "displays it on the node itself" part.

    Inputs and outputs

    The single input is folder_path (STRING, multiline) - that's it, nothing optional to configure.

    The two outputs are folder_path_out (STRING) and file_count (INT). file_count is the one you'll actually wire somewhere: into a Primitive-style math chain, a filename prefix, or a comparison that decides whether to keep looping. folder_path_out gives you back the sanitized version of what you typed - handy if you pasted a messy path and want to see what the node actually resolved.

    Installing it

    The whole Allergic Pack ships together, so one install gets you all four nodes. Easiest: ComfyUI Manager → search "Allergic Pack" → install the latest release (skip the nightly unless you enjoy fiddling with security levels). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/usrname0/ComfyUI-AllergicPack.git
    cd ComfyUI-AllergicPack
    pip install .    # Windows portable: ..\..\..\python_embeded\python.exe -m pip install .
    

    Then restart ComfyUI. Good news on the heavy-lifting front: the pack's requirements.txt is empty. No torch or CUDA pins, no model downloads, nothing extra - it only touches things ComfyUI already ships. You'll find the node under "Allergic Pack" in the node menu.

    Bottom line

    It's a tiny node, and it knows it. If you already count files in a shell before you hit Queue, you don't need this. But the moment you're building a workflow that consumes a folder's file count at runtime - for batch math or an "am I out of images?" check - this is the low-friction way to get the number into the graph.

    CategoryAllergic Pack

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRINGEnter folder path - filesystem-unfriendly characters will be automatically cleaned

    Outputs (2)

    NameTypeDescription
    folder_path_outSTRING
    file_countINT