imagesCountInDirectory
imagesCountInDirectory node from ComfyUI-Easy-Use.
images Count In Directory
The imagesCountInDirectory node returns the number of image files in a given directory, optionally skipping a number of files at the beginning and limiting how many are counted. It is useful when you need a dynamic image count to pass to other nodes, for example to build batch sizes or to know how many images remain after some offset.
Inputs
-
directory (STRING, required): The filesystem path to the directory containing the image files. The node scans this folder for supported image formats (such as
.png,.jpg,.jpeg,.webp,.bmp, etc.). -
start_index (INT, required): The number of images to skip before counting begins. The default is
0, meaning counting starts from the first image in directory order. Ifstart_indexis greater than or equal to the total number of images, the count is0. -
limit (INT, required): The maximum number of images to count. The default is
-1, which means no limit and all remaining images afterstart_indexare counted. If set to0, the result is0even if images exist. If a positive value is used, the count will not exceed this number, and it will be clamped to the number of available images.
Outputs
- INT: The number of image files that satisfy the
start_indexandlimitconstraints. For example, withstart_index = 2andlimit = 3, the node returns the number of images that would be available from the 3rd image onward, up to a maximum of 3.
Usage Notes
- The directory is expected to be a local path accessible by ComfyUI.
- Image files are counted in whatever order the directory listing returns, so if your workflow depends on a specific ordering, name files accordingly (e.g. with zero-padded numbers).
- This node only counts files; it does not load or return image data. Pair it with loader or list nodes that consume the resulting integer.
limit = -1is the typical “count everything” setting and is the default.
Comments
Sign in with GitHub to join the discussion.