Update Readme

This commit is contained in:
Rocky-PC
2026-01-25 17:54:20 +08:00
parent b97b2486e1
commit f9e74dae8f
3 changed files with 38 additions and 13 deletions
+38 -13
View File
@@ -4,7 +4,7 @@ Load file paths **from a folder by extension** (`*.png`, `*.mp4`, `*.txt`, etc.)
This repo is mainly for **easy batch processing**:
- Use it with your favorite loop/for/while node pack (pick items by index), or
- Use this repo’s simple loop node (`FilePathsForLoop`) to have ComfyUI run downstream nodes **once per file** (list batching).
- Use this repo’s simple loop node (`File Paths For Loop Start`) to have ComfyUI run downstream nodes **once per file** (list batching).
## Installation
@@ -18,7 +18,7 @@ git clone https://github.com/RockyHong/ComfyUI-FilePathsFromFolder.git
```
2. Restart ComfyUI
3. Search nodes by name: `Load File Paths From Folder`, `Get File Path By Index`, `File Paths For Loop Start`
3. Search nodes by name: `Load File Paths From Folder`, `Get File Path By Index`, `File Paths For Loop Start`, `File Paths Loop Sync`
### Alternative: Manual install (ZIP)
@@ -51,35 +51,60 @@ Use this when you already have an external loop/for/while node pack and you want
<a id="option-b-internal-loop"></a>
## Built-in simple for-loop node (list batching)
Use this when you want the simplest setup: `FilePathsForLoop` returns lists, and ComfyUI runs downstream nodes **once per file** via list batching. (UI: `File Paths For Loop Start`)
Use this when you want the simplest setup: `File Paths For Loop Start` returns lists, and ComfyUI runs downstream nodes **once per file** via list batching.
### Nodes used
- `FilePathsForLoop`: generates the per-file list outputs (`current_filepath`, `current_index`, etc.) (UI: `File Paths For Loop Start`)
- (Optional) `FilePathsEnsureExecution`: “anchors” a route so it definitely runs (useful for save/write/export routes) (UI: `File Paths Loop Ensure Execution`)
- `FilePathsLoopClose`: loop terminator / completion signal (UI: `File Paths Loop End`)
- `File Paths For Loop Start`: generates the per-file list outputs (`current_filepath`, `current_index`, etc.)
- `File Paths Loop End`: loop terminator / completion signal
### Example workflow (internal loop: once per file)
![Option B — Internal Loop Node Method](screenshots/Option%20B%20(Interal%20Loop%20Node%20Method).jpg)
1. `FilePathsForLoop` (set folder path + extension)
1. `File Paths For Loop Start` (set folder path + extension)
2. `current_filepath` → your loader node (e.g. Load Image)
3. Your processing nodes
4. (Optional) outputs you want to **guarantee run** (e.g. save/write/export nodes) → `FilePathsEnsureExecution.passthrough_1` … `passthrough_5`
5. `current_index` → `FilePathsLoopClose.current_index`
6. (Optional) `FilePathsEnsureExecution.passthrough` → `FilePathsLoopClose.passthrough` (this “anchors” the route so it executes)
5. `current_index` → `File Paths Loop End.current_index`
6. (Optional) `FilePathsEnsureExecution.passthrough` → `File Paths Loop End.passthrough` (this “anchors” the route so it executes)
### Memory note
`FilePathsForLoop` uses **ComfyUI list batching** (`OUTPUT_IS_LIST`): ComfyUI may run the workflow **one node at a time for all files**, rather than finishing file 0 completely before starting file 1.
`File Paths For Loop Start` uses **ComfyUI list batching** (`OUTPUT_IS_LIST`): ComfyUI may run the workflow **one node at a time for all files**, rather than finishing file 0 completely before starting file 1.
- **What you’ll see**: it may run like **“load all → process all → save all”**, not “load → process → save” per file.
- **When this is good**: if you want to run many files with the **same model/settings**, batching can help keep the model “warm” and avoid offload/reload each file.
- **What you'll see**: it may run like **"load all → process all → save all"**, not "load → process → save" per file.
- **When this is good**: if you want to run many files with the **same model/settings**, batching can help keep the model "warm" and avoid offload/reload each file.
- **Why memory can climb**: more intermediate results may stay in RAM/VRAM until later nodes run.
- **Tip**: if memory keeps increasing, add a “Clean VRAM” / “Clean RAM” (or similar) node after heavy steps.
- **Solution for mid-batch cleanup**: Use `File Paths Loop Sync Trigger` + `File Paths Loop Sync Resume` to run cleanup **once** between batch stages (see [Batch Synchronization](#batch-sync) below).
- **Need true one-file-at-a-time?** Use an external loop/for/while node pack that runs each file start→finish before moving on.
### (Optional) Ensure execution for save/write/export routes
Some ComfyUI workflows can “skip” routes that don’t affect the final output the graph thinks it needs. If you have save/write/export nodes that you **must** run, use `File Paths Loop Ensure Execution` (`FilePathsEnsureExecution`) as an anchor.
![File Paths Loop Ensure Execution](screenshots/File%20Paths%20Loop%20Ensure%20Execution.jpg)
- Connect the nodes you want to guarantee run into `passthrough_1` … `passthrough_5`
- Connect `passthrough` output to `File Paths Loop End.passthrough`
<a id="batch-sync"></a>
## Batch synchronization (run once between stages)
Use this when you need to run something **exactly once between two batched stages** (e.g. LLM batch → clear VRAM once → T2I batch), without switching to an external per-file loop.
- **`File Paths Loop Sync Trigger`**: put this right after a batched output. It provides:
- **`anything`**: the original batch (passes through unchanged)
- **`trigger`**: a single (non-batched) value you can feed into **any “run once”** node
- **`File Paths Loop Sync Resume`**: a simple wait point. It:
- Takes the batch on **`anything`** (from Trigger)
- Takes a completion signal on **`wait_for`** (from your one-time node)
- Outputs the same batch so downstream nodes continue as a batch
**How to wire it (in words):** connect your batched data into `Sync Trigger` → connect `Sync Trigger.anything` into `Sync Resume.anything` → connect `Sync Trigger.trigger` into your one-time node → connect that one-time node’s output into `Sync Resume.wait_for` → continue the workflow from `Sync Resume.anything`.
**What you can run once:** clear RAM/VRAM, save/checkpoint, switch models, send notifications, write logs, etc.
## License
MIT — see `LICENSE`.
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB