Nodes/ComfyUI-Line-counter/Directory File Counter ⏲️
ComfyUI Node

Directory File Counter ⏲️

How many files are in a folder, as a workflow value

By ChrisColeTech·Created 2 years ago·Updated about a year ago· 2
Directory File Counter ⏲️
    • INT
    • FLOAT
    • STRING
    directory_path

    Point this at a folder, and it hands back how many files are in it - as an actual number in your graph, not something you have to eyeball in a file browser first. It's a tiny node doing one honest job: turning "how many files are in this directory" into a value you can wire somewhere else. The pack's own README sums up the intent well - "ideal for managing and auditing file structures quickly."

    Where this earns its keep is anywhere ComfyUI is standing in for a script. Auditing a dataset folder before a LoRA training run to confirm it actually has the image count you think it does. Feeding a total into something that drives a fixed number of queue runs - Impact Pack's Queue Trigger and similar batch-loop nodes need a total to count down from, and this saves you opening the folder and counting by hand. Or just a sanity check wired into a Show Text node before you kick off anything that touches every file in there.

    How it works

    directory_path is a plain text field - you type or paste a path, the node lists that directory server-side and counts what's in it. There's no extension filter in the schema, so it counts everything sitting in that folder: images, stray .DS_Store or thumbnail-cache files, text sidecars, all of it. If you need "how many .png files," you're counting a folder that only has .png files in it, not filtering one that doesn't.

    The inputs and outputs that matter

    Just one input that matters: directory_path (a STRING, empty by default) - the folder to count.

    Three outputs, all the same count in different types - INT, FLOAT, STRING - so you wire whichever socket the next node actually wants without reaching for a type-convert node in between.

    Installing it

    ComfyUI Manager: search ComfyUI-Line-counter, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ChrisColeTech/ComfyUI-Line-counter.git
    

    Restart ComfyUI. No models, no extra Python packages - this is plain filesystem I/O, nothing to download.

    Common issues and troubleshooting

    The path has to exist on whatever machine is actually executing the workflow. That's an easy trap: directory_path is a bare text box with no folder browser or autocomplete, so a typo or a path copied from a different machine just gets you an error or a count of zero, not a helpful hint about what went wrong.

    It also matters where that machine is. On a local ComfyUI install, "the machine running the workflow" is your own PC, so any folder you can see in Explorer or Finder is fair game. If you're running the workflow through a cloud executor rather than your own desktop, "point it at my Downloads folder" doesn't work the way it would locally - the path needs to exist inside whatever filesystem the run actually has access to, which usually means files staged into that run rather than a path from your own computer. This node was clearly built with a local install in mind; keep that in the back of your head if the count comes back as zero and the folder "definitely has files in it."

    One more small one: Windows-style backslashes in a path can trip up string handling in some setups. If a path with backslashes errors, retyping it with forward slashes is the safe first thing to try.

    Category🤖 CCTech/Files

    Inputs (1)

    NameTypeDefaultDescription
    directory_pathSTRING

    Outputs (3)

    NameTypeDescription
    INTINT
    FLOATFLOAT
    STRINGSTRING