π Directory Image Loader
Load image number N from a folder, filename included
- image
- filename
Directory Image Loader is the "load a specific image from a folder by number" node. ComfyUI's built-in loader only sees images you've dropped into input/; this one takes any absolute directory path and an index, and returns the image at that position in the folder, sorted alphabetically - plus the filename, so you know which one you actually got.
That's the key difference from the built-in loader, and it's why you'd reach for it: batch and dataset work. Point it at a folder of reference images or a training-style set, drive the index from a loop or an incrementing counter, and you've got a pipeline that walks through a directory without you hand-picking files. The filename output is the underrated part - wire it to a Show Text or a filename-aware save node and your outputs can be named after their source instead of the usual timestamp soup.
How it works
It lists the directory, filters to image extensions (.jpg, .jpeg, .png, .bmp, .tiff, .tif, .webp, .gif), sorts the names alphabetically, and loads the one at your index. The file gets converted to RGB if needed and normalized into a standard ComfyUI batch tensor, ready to wire into anything that takes an IMAGE. No recursion into subfolders, no randomization.
The one behavior worth memorizing: on any error - bad path, empty folder, index out of range - it doesn't throw and stop the graph. It returns a solid 512Γ512 black image and a filename that starts with ERROR: . That's a graceful fallback, but it's also a silent failure: the graph keeps running on a black image you might not notice.
Inputs and outputs
directory_path(STRING) - absolute path to the folder.index(INT, default0, up to 999999) - which image, after alphabetical sorting.0is the first.image(IMAGE) - the loaded image tensor.filename(STRING) - the actual file name at that index.
Installing it
Part of the Skycoder Tools pack:
cd ComfyUI/custom_nodes
git clone https://github.com/skycoder182/comfyui-skycoder-tools.git
# then restart ComfyUI
Or ComfyUI Manager β "Install Custom Nodes" β search "Skycoder Tools" β Install β restart. No models, no extra dependencies.
Common issues
The black-image fallback is the thing that will bite you, because nothing looks wrong. If your outputs suddenly go black, check whether the index is inside the folder's range. Second: the index maps to alphabetical order, so index 0 is the file that sorts first (think IMG_0100 before IMG_0200). Run the pack's Directory Image Info node on the same folder first - it lists the first five names and the total count, so you know exactly what each index points to before you commit a long batch to it. And if a folder has no images at all, you get the black image plus an ERROR: ... filename, which is your cue to check the path.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| directory_path | STRING | β | |
| index | INT | 00β999999 | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| filename | STRING | β |