# ComfyUI-image-counter
A lightweight utility node to count images in a folder and extract folder names.
### Features
- Counts image files .png, .jpg, .jpeg, .webp, .bmp, .tiff) without loading them into VRAM/RAM.
- Extracts current and parent folder names for dynamic output paths (e.g., SaveImage).
- Outputs a preview string for display or subgraph passthrough.
- Cache disabled IS_CHANGED): forces re-scanning the directory on every queue.
- Zero dependencies (pure Python standard library).
### Installation
Extract the folder into ComfyUI/custom_nodes/ and restart ComfyUI.
### Inputs
- directory (STRING): Absolute path to the folder.
### Outputs
1. count (INT): Total number of valid images.
2. parent_folder_name (STRING): Name of the parent directory.
3. folder_name (STRING): Name of the current directory.
4. preview (STRING): Formatted status text (e.g., 已识别到: XX 张图片).
---
## 中文说明
一个轻量级的 ComfyUI 工具节点,用于统计文件夹内的图片数量并提取文件夹名称。
### 功能
- 快速统计指定文件夹内的图片总数(不占用显存与内存)。
- 自动提取当前及上一级文件夹名称,便于直接对接保存路径(如 SaveImage)。
- 输出格式化文本,便于在画布或子图外部实时预览状态。
- 禁用节点缓存IS_CHANGED):每次触发队列均重新扫描磁盘,避免旧数据残留。
- 零第三方依赖(纯 Python 标准库实现)。
### 安装方式
将整个文件夹解压放入 ComfyUI/custom_nodes/,重启 ComfyUI 即可。
### 输入端
- directory (STRING):目标文件夹的绝对路径。
### 输出端
1. count (INT):图片总数。
2. parent_folder_name (STRING):上一级文件夹名称。
3. folder_name (STRING):当前文件夹名称。
4. preview (STRING):用于界面显示的预览文本。
