Random Filepath Sampler π²
Pick a random file from a folder β with extension filters, subdirectories, and regex
- filepath
Eden_RandomFilepathSampler picks a random file from a directory and hands you its path as a string. On its own that's a party trick, but wired into a loader it becomes "random image/prompt/LoRA from my folder" - the backbone of batch variety workflows where you want a different input every run. It's the file-sampling cousin of the pack's random prompt and number samplers.
How it works
You give it a directory_path and a seed. It lists the files, applies any filters you set, and uses Python's seeded random.choice to pick one - so same seed, same pick, reproducible. The filtering is where it gets genuinely useful:
- file_extension - restrict to, say,
.jpg(it adds the leading dot for you if you forget). - include_subdirectories - walk the whole tree instead of just the top level.
- filter_string + filter_mode - keep only filenames that
contains,starts_with,ends_with, orregex-match the string. - case_sensitive - whether that filter cares about case.
Hidden dotfiles are always excluded, and ~ in the path gets expanded, which is a small nice touch. The output is a full path string ready to hand to a loader that takes a filename.
Inputs
- directory_path (
STRING, default./) - where to look. - seed (
INT, default 0) - reproducibility. - Optional: file_extension, include_subdirectories, filter_string, filter_mode, case_sensitive.
Output: filepath (STRING).
Where it fits
Batch pipelines are the home turf. Point it at a folder of reference images and feed the path into an image loader for randomized reference/controlnet input. Point it at a folder of LoRAs or embeddings and you get random style sampling. The filter modes matter for production: filter by _neg suffix, or regex to exclude files. It pairs naturally with the pack's other random nodes - seed it consistently and your whole "random but reproducible" batch stays in lockstep across runs.
Installing it
Part of the Eden.art nodesuite. Install via ComfyUI Manager (search "Eden.art nodesuite") or git clone https://github.com/edenartlab/eden_comfy_pipelines into custom_nodes/, then pip install -r requirements.txt and restart.
Common issues
Two classic failures. First: "no files found" - the node raises a clear error when nothing matches your filters; check the extension (a file_extension of jpg vs .jpg - either works, but mismatch the case with case_sensitive on and you'll get nothing). Second, and sneakier: the node runs relative to ComfyUI's working directory, so a relative path like ./ isn't necessarily where you think it is. Use an absolute path unless you're sure. And if you're feeding the result into a loader that wants just a filename rather than a full path, this node gives you the full path - you may need a basename node after it.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| directory_path | STRING | ./ | β |
| seed | INT | 00β18446744073709550000 | β |
| file_extensionopt | STRING | β | |
| include_subdirectoriesopt | BOOLEAN | false | β |
| filter_stringopt | STRING | β | |
| filter_modeopt | COMBO | contains | 4 options: contains, starts_with, ends_with, regex |
| case_sensitiveopt | BOOLEAN | false | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| filepath | STRING | β |