Nodes/comfyui_LLM_party/File Path Iterator
ComfyUI Node

File Path Iterator

Step through a folder one file at a time in ComfyUI

By heshengtao·Created 2 years ago·Updated 7 days ago· 2,321
File Path Iterator
    • file_path
    • is_end
    folder_path
    extension.png,.jpg,.jpeg,.gif,.bmp
    is_enabletrue
    is_reloadfalse
    iterator_modesequential

    ComfyUI has no built-in "for each file in this folder" node. You either hardcode one path per run or you reach for something like this. File Path Iterator, from the sprawling comfyui_LLM_party pack, is the low-drama answer: point it at a folder, hit run repeatedly, and each pass it hands you the next file path in line instead of the same one.

    It's buried in a pack built mostly for LLM agents and RAG pipelines, but this particular node doesn't care what you do with the path - feed it into a Load Image node, a VLM captioning chain, a text loader, whatever. Anywhere you'd otherwise be manually swapping a filename in a widget between runs, this replaces that chore.

    How it works

    The node keeps track of where it left off. Every time the graph executes, it reads the folder, filters files by extension, and returns the next one according to whichever mode you picked. It's stateful across runs within the same session - that's the entire trick, and it's also the thing to watch (see below).

    The inputs and outputs that matter

    • folder_path - the directory to walk. No default, so you have to fill it in.
    • extension - a comma-separated filter, defaulting to .png,.jpg,.jpeg,.gif,.bmp. Swap this out if you're iterating text files, SRTs, or anything non-image - the pack's other nodes (subtitle parsers, file loaders) all take plain paths, so this isn't locked to images despite the default.
    • iterator_mode - sequential (one after another, in order), random (a shuffle each pull), Infinite (loops back to the start once exhausted instead of stopping), and sequential_flagout (sequential, but signals when it's done - see is_end).
    • is_reload - force it to re-scan the folder and reset position, useful if you dropped new files in mid-session and the iterator is still working off a stale listing.
    • is_enable - the pack's standard kill-switch pattern; flip it off to bypass the node without deleting it from the graph.

    Outputs: file_path (STRING, wire it straight into whatever loader you're using) and is_end (BOOLEAN, flips true once you've stepped past the last file in sequential_flagout mode). Plain vanilla ComfyUI graphs can't loop on themselves, so is_end is really meant for driving the run count externally - via the API, a batch script, or a queue-count you bump - rather than something a static graph can react to on its own.

    How to install it

    Search comfyui_LLM_party in ComfyUI Manager and install - it's a big pack, so the install pulls in everything else that ships alongside it, not just this one node. Manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/heshengtao/comfyui_LLM_party.git
    

    Then, from inside the comfyui_LLM_party folder, run pip install -r requirements.txt using ComfyUI's own Python - not your system Python - and restart. If dependency resolution fights you (this pack bundles a lot: LLM clients, embedding libraries, OCR, TTS), the README ships a requirements_fixed.txt with pinned versions as a fallback.

    Common issues & troubleshooting

    It keeps returning the same file, or skips files you just added. That's is_reload - toggle it on for one run to force a fresh folder scan, since the node otherwise trusts its last-known listing.

    Nothing comes back at all. Check extension first; it's an exact-match filter against the file suffix, so a folder full of .PNG (uppercase) against a lowercase filter list can come up empty depending on how the match is implemented - try adding the uppercase variant if files aren't showing up.

    You expected it to stop and it didn't. Only sequential_flagout sets is_end; plain sequential and Infinite will just keep re-running or wrap around forever, which is by design, not a bug - pick the mode that matches whether you want a hard stop.

    Category大模型派对(llm_party)/迭代器(iterator)

    Inputs (5)

    NameTypeDefaultDescription
    folder_pathSTRING
    extensionSTRING.png,.jpg,.jpeg,.gif,.bmp
    is_enableBOOLEANtrue
    is_reloadBOOLEANfalse
    iterator_modeCOMBOsequential4 options: sequential, random, Infinite, sequential_flagout

    Outputs (2)

    NameTypeDescription
    file_pathSTRING
    is_endBOOLEAN