Nodes/ComfyLab Pack/File Queue (lab)
ComfyUI Node

File Queue (lab)

Loop every file in a folder without hand-typing a single path

By bugltd·Created 2 years ago·Updated about a year ago· 11
File Queue (lab)
  • index
  • filename
  • full_path
  • relative_path
  • subfolder
  • index
  • total
folder
pattern*
recursivetrue
with_extensiontrue

File Queue (lab) scans a folder for files matching a pattern (or several), and hands them to your workflow one at a time, auto-queuing through the whole batch. It's the file-driven sibling of Image Queue (lab) - same scanning engine, except it outputs filenames and paths instead of loading the image for you. You use it when the thing you're iterating is a set of files: captions, prompts, configs, batch-processing scripts - or when you want the paths so you can hand them to another tool.

The practical win: point it at a folder, and a workflow that processes one file becomes a workflow that processes a thousand. No counters, no queue size management - same auto-queue behavior as the rest of the pack.

How it works

On the first run it scans the folder once (not per iteration), using Python's glob with the pattern, which has a nice side effect: it follows symlinks, and the author's changelog notes that support was added deliberately. Multiple patterns are supported, comma-separated. Files are de-duplicated and sorted with the current folder's files first.

Inputs:

  • folder - where to look.
  • pattern - default *; e.g. *.txt or prefix*. Comma-separated for multiples: *.txt, *.md.
  • recursive - default true, scans subfolders.
  • with_extension - default true; off strips extensions from the filename output.

Outputs, all the paths you could want:

  • filename - just the name (with or without extension).
  • full_path - absolute-ish path as scanned.
  • relative_path - relative to the scanned folder.
  • subfolder - the relative subfolder (added in v0.0.9; useful for recreating structure elsewhere).
  • index / total - progress, 1-based.

The optional index input (QUEUE_STATUS) exists for chaining queues, same as the other queue nodes.

Where it earns its keep

  • Prompt batches - point it at a folder of .txt prompt files, read each file's content, queue through them.
  • Captioning / tagging pipelines - feed filenames into whatever node names your outputs, keeping image and text in lockstep.
  • Save-text loops - pair with a save node and the full_path/subfolder outputs to replicate a folder tree in your output directory.

If you're doing all this and you need the images loaded, Image Queue does the file work and the image loading in one node - prefer it there.

Install

ComfyLab Pack is one install for its whole family (look for "(lab)" in node names). ComfyUI Manager: search ComfyLab Pack, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/bugltd/ComfyLab-Pack.git
cd ComfyLab-Pack
pip install -r requirements.txt

Restart after. No model downloads; requirements are light (opencv-python, pyyaml, jsonschema and a few small ones).

Gotchas

  • "No file found" is a loud error, not a silent pass - the node raises if the folder is empty or nothing matches. Annoying during setup, but it beats a workflow that quietly does nothing.
  • The folder must exist and be a directory - same backend-filesystem reminder as the rest of the pack: paths resolve on the machine running ComfyUI.
  • Scan happens once, at index 0. Files added mid-run aren't picked up; restart the run.
  • Symlinked paths stay as scanned - relative_path is computed without resolving links, which is intentional but can surprise you if your folder is a symlink farm.

It's the node you build one "process this whole directory" workflow with and then reuse forever. Set the folder, set the pattern, walk away.

CategoryComfyLab/queue

Inputs (5)

NameTypeDefaultDescription
folderSTRINGfolder to scan
patternSTRING*file pattern(s) to match, e.g. '*.txt' or 'prefix*'. multiple patterns can be defined, separated by a comma
recursiveBOOLEANtruescan recursively?
with_extensionBOOLEANtruekeep or remove file extension
indexoptQUEUE_STATUScurrent queue status

Outputs (6)

NameTypeDescription
filenameSTRINGfilename
full_pathSTRINGfull path
relative_pathSTRINGrelative path
subfolderSTRINGsubfolder (relative)
indexINTcurrent index
totalINTtotal files