Text File Info
Peek at a prompt file before you use it
- line_count
- file_name
You know how everyone keeps their reusable prompts and captions in .txt files inside ComfyUI's input folder? This node is the little utility that tells you what's in one of those files before you shove it into a workflow - specifically, how many usable lines it has and what it's called. XJTextFileInfo takes a file picker, reads the file, and hands you back a line count plus the filename as plain values you can wire into anything.
The detail worth understanding is what it counts, because it's not the raw line count. It reuses the exact same parsing as the pack's Random Text From File node: it strips leading whitespace and - list prefixes, drops empty lines, and ignores anything starting with #. So a file with a header comment, blank lines, and twenty actual prompt lines reports 20, not 23. If you're pairing this with a node that picks a random line or a list built from the same file, the count you get here is the count that matters - they agree, because they share the same parser. That consistency is the whole point; a naive wc -l would lie to you.
The interface, which is minimal:
file_path- a dropdown that enumerates.txtand.mdfiles in the input directory, pre-sorted. Pick one.- Outputs:
line_count(INT) andfile_name(STRING).
Where it earns its keep: driving a random-prompt workflow. Feed line_count into a random INT or a range generator to pick a valid line index without going out of bounds, then wire file_name somewhere for logging or display. It's also handy as a sanity check when you've dropped a new file into input and ComfyUI's file list hasn't refreshed - you can confirm the file is visible and populated before your workflow depends on it. If the file doesn't exist (it got moved, or the path is stale), it safely returns a count of 0 rather than crashing.
Install is the standard pack story:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
Restart ComfyUI and look under XJNodes/text, or install via ComfyUI Manager by searching "ComfyUI-XJNodes". No models to download, no extra pip dependencies - requirements.txt is empty.
Reality check: this is a personal-use pack and the node is a convenience wrapper around len() with better parsing. But if you're building prompt-batching workflows that read from files, having the count as a wire instead of a guess is one less thing to break silently.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | COMBO | 1 options: |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| line_count | INT | — |
| file_name | STRING | — |