EasyUse/Imagegenerated

imagesCountInDirectory

imagesCountInDirectory node from ComfyUI-Easy-Use.

images Count In Directory

count
directory
STRING
start_index
0
limit
-1
Easy Use

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. If start_index is greater than or equal to the total number of images, the count is 0.

  • limit (INT, required): The maximum number of images to count. The default is -1, which means no limit and all remaining images after start_index are counted. If set to 0, the result is 0 even 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_index and limit constraints. For example, with start_index = 2 and limit = 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 = -1 is the typical “count everything” setting and is the default.

Comments

Sign in with GitHub to join the discussion.

Loading comments…