Nodes/petty-paint-comfyui-node/Petty Paint Count Files
ComfyUI Node

Petty Paint Count Files

Know how many files are in a folder before you commit

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
Petty Paint Count Files
  • value
  • INT

Counting files sounds like the most boring node imaginable, until you're building a batch workflow and realize you'd love to know, inside the graph, whether a folder has 40 images or 4. PettyPaintCountFiles does one thing: it takes a folder path, walks it recursively, and returns the number of files found. That integer can drive a batch-size calculation, a progress check, or a conditional branch - "if this folder already has 50 outputs, skip the run."

The mechanism is exactly what you'd hope: an os.walk that sums up len(files) per directory, so it counts every file in every subfolder, not just the top level. That recursive behavior is worth remembering when you use it - point it at a folder that contains subfolders and the number includes everything beneath. It's one of a small cluster of filesystem utilities in this pack (alongside EnsureDirectory and FileExists), and they're the kind of thing people quietly slot into automation-heavy workflows where a human normally checks "is this done yet."

The inputs and outputs

  • value - any type (*), but practically the folder path as a string.
  • Output: INT - the file count, despite the output being declared as a wildcard. It's an integer; use it anywhere an INT is expected.

Installing it

It's part of the petty-paint pack:

cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node

Restart ComfyUI, or install via ComfyUI Manager searching "petty-paint-comfyui-node". Declared dependency: Flask==2.1.2, unused here.

Common issues

The main way people get tripped up is the output type declaration. The schema says the output is a wildcard (*), and ComfyUI will let you wire it almost anywhere - but the value is genuinely an integer, so connecting it to a STRING slot downstream will pass a number and can produce surprising results. If you need text, convert it. Also, "recursive" is a feature and a trap: a folder with a thousand-image dataset plus per-image sidecar subfolders will count the sidecars too, and nobody loves debugging an off-by-thousands batch because of it. Finally, the input is unvalidated - give it a nonexistent path and you get 0, silently. Pair it with the pack's PettyPaintFileExists if you need to distinguish "empty folder" from "wrong path."

CategoryPettyPaint

Inputs (1)

NameTypeDefaultDescription
value*

Outputs (1)

NameTypeDescription
INT*