ComfyUI Node

πŸ“‚ File Count

How many frames are actually in that folder? One node, no shell required

By alt-key-projectΒ·Created 3 years agoΒ·Updated 2 years agoΒ· 114
πŸ“‚ File Count
    • TOTAL
    β—„directory_pathβ–Ί
    β—„patterns*.jpg|*.png|*.jpegβ–Ί

    Resuming an interrupted animation render is one of those moments where a tiny utility node saves you real time. File Count [Dream] looks at a directory and tells you how many image files match your patterns - which is exactly the number you need when a render died at frame 300 of 1200 and you want to pick up where it left off.

    It comes from the Dream Project Animation Nodes pack (alt-key-project), the 2023 Deforum-style animation toolkit. Like the rest of the pack it's no longer actively updated, but this is a ten-line node that doesn't need updates.

    How it works

    Two inputs, one output. Give it a directory_path and patterns, and it counts the files:

    • directory_path - the folder to scan
    • patterns - a |-separated list of glob patterns, default *.jpg|*.png|*.jpeg

    Output is TOTAL, an INT with the combined count across all patterns. If the directory doesn't exist, it returns 0 instead of erroring - which is a small kindness that keeps a broken path from killing the whole graph.

    Under the hood it's glob summing each pattern. It also re-evaluates via IS_CHANGED whenever the file count changes, so ComfyUI won't serve you a stale count if you add frames mid-session.

    Why you'd bother

    Three genuine uses:

    1. Resumable renders. Pair it with Frame Counter (Directory), which derives its position from files on disk. Count what's there, feed it somewhere that needs to know, and a crashed render restarts at the right place.
    2. Feeding totals. Set total_frames on a frame counter from the actual number of rendered frames instead of guessing. If you already have 400 frames and want a tweening pass, that number is your input.
    3. Sanity checks. Before you feed a folder to Image Sequence Loader, confirm it actually contains what you think. A typo in the path silently returns 0 - that's often the real bug, and this node surfaces it.

    It's the boring kind of node you forget exists until you need it, then you're glad it does.

    Installing

    cd ComfyUI/custom_nodes
    git clone https://github.com/alt-key-project/comfyui-dream-project.git
    

    Or via ComfyUI Manager under "Dream Project Animation". No model downloads; the whole pack just needs imageio, scipy, torchvision, pilgram, and evalidate. Mind the numpy<2.0 pin if you see NumPy conflicts elsewhere. It lives under Dream β†’ animation.

    Category✨ Dream/πŸŽ₯ animation

    Inputs (2)

    NameTypeDefaultDescription
    directory_pathSTRINGβ€”
    patternsSTRING*.jpg|*.png|*.jpegβ€”

    Outputs (1)

    NameTypeDescription
    TOTALINTβ€”