A ComfyUI custom node that enables loading text content from files within a specified directory. This node is particularly useful for batch processing of text files, allowing sequential, single-file, or random access to text content.
-
mode (Required)
single_file
: Loads a specific text file based on the indexincremental_file
: Loads files sequentially, cycling back to the beginning when reaching the endrandom
: Loads a random text file using the provided seed
-
seed (Required)
- Default: 0
- Range: 0 to 18446744073709551615
- Used for random file selection when mode is set to "random"
-
index (Required)
- Default: 0
- Range: 0 to 150000
- Step: 1
- Specifies which file to load in "single_file" mode or starting point in "incremental_file" mode
-
label (Required)
- Default: 'Text Batch 001'
- A label for the text batch being processed
-
path (Required)
- Default: '' (empty string)
- The directory path containing the text files to be loaded
-
pattern (Required)
- Default: '*'
- File pattern for matching text files (e.g., '.txt', 'chapter.md')
.txt
files.md
files
The node provides two outputs:
- text: The content of the loaded text file
- filename_text: The name of the loaded file
Use this mode when you want to load a specific text file by its index:
- Set
mode
to "single_file" - Set
path
to your text files directory - Set
index
to select the specific file (0 for first file, 1 for second, etc.)
Use this mode for sequential processing of text files:
- Set
mode
to "incremental_file" - Set
path
to your text files directory - Set
index
to define the starting point - Files will be processed sequentially from the starting index
Use this mode to randomly select text files:
- Set
mode
to "random" - Set
path
to your text files directory - Set
seed
to control random selection (same seed will always select the same file)
The node includes error handling for common issues:
- Invalid directory paths
- Invalid file indices
- File reading errors
Files are automatically sorted alphabetically within the directory to ensure consistent ordering across different modes.