The Captions To Prompt List node is designed to combine multiple caption text files from a directory into a single consolidated list. This node is particularly useful when working with datasets that contain multiple caption files and you need to merge them into a single prompt list.
- directory_path (STRING)
- The path to the directory containing caption text files
- Default value: "/path/to/dataset"
- Should point to a directory containing .txt files with captions
- reload (BOOLEAN)
- Controls when the node should reload and reprocess the files
- Default value: False
- Two modes:
- "if file changed" (True): Reloads when file contents change
- "if value changed" (False): Reloads only when the directory path changes
The node performs the following operations:
- Walks through the specified directory and its subdirectories
- Reads all .txt files found in the directory structure
- Combines all captions from these files into a single list
- Generates an output filename based on the input directory name
- Only processes files with .txt extension
- Ignores .png files silently
- Logs when it ignores other file types
- Handles UTF-8 encoded text files
- Processes each caption file line by line
The node returns two values:
-
combined_captions (STRING)
- All captions combined into a single string
- Each caption is separated by a newline
- Maintains the original order of captions within each file
-
output_filename (STRING)
- Generated filename for the combined captions
- Created by taking the last directory name from the path and adding .txt extension
- Example: If path is "/data/my_dataset", output filename will be "my_dataset.txt"
-
Error Handling:
- The node will attempt to process each .txt file independently
- If an error occurs while processing a specific file, it will:
- Print an error message with the file path and error details
- Continue processing remaining files
- UTF-8 encoding is required for text files
-
Reload Behavior:
- When reload is False: Only reprocesses when directory path changes
- When reload is True: Uses MD5 hashing to detect changes in file contents
- Hash calculation includes both filenames and file contents
- Ensures efficient processing by only reloading when necessary
-
The node is categorized under "custom/text" in the ComfyUI interface