EmAySee Filename Trigger Parser
Turn coded filenames into prompt triggers — 'img_02_v1.png' becomes 'young adult'
- trigger
Here's the workflow this node exists for: you batch-generate images, and you've agreed that the filename encodes something about the image - girl_01_poseA, man_02_poseB, whatever your convention is. Now you want to feed that code back into the graph as a text value, because the next stage's prompt depends on it. This node splits the filename on a separator, pulls out the segment you care about, and maps it through a code→value table you define. 01 becomes teen, 02 becomes young adult. Filename convention in, useful text out.
How it works
It takes the filename, strips the extension and any directory path (so O:/outputs/img_01_v2.png and img_01_v2.png both work), splits the base name on separator (default _), and grabs the segment at target_index. That code is then looked up in up to five code→value mappings - map_1_code → map_1_value, and so on through map_5. If the code matches a mapping, you get the mapped value; if it doesn't match (or the mapping's value is empty), you get fallback_value.
Two details from the source worth knowing:
target_indexis zero-based in the code. The default is 1, which means the second segment (img_01_v2splits intoimg,01,v2; index 1 =01). If your codes are the first segment, set it to 0.- Empty mappings are inert. A blank
map_4_code/map_4_valuepair simply never matches, so the defaults leave slots 4 and 5 unused without breaking anything.
Inputs and outputs
filename(STRING, forced input) - wire it from a Load Image's filename output or a Save Image's file path.separator(STRING, default_)target_index(INT, 0–10, default 1) - which segment holds the code.map_1_code/map_1_value…map_5_code/map_5_value- your lookup table.fallback_value(STRING, default empty) - returned when nothing matches.
Output: trigger, a STRING. Feed it into a prompt template, a selector, or downstream logic - e.g., concatenate it into a CLIP text encode so the next stage's prompt conditionally mentions the attribute the filename encoded.
Install
Part of ComfyUI_EmAySee_CustomNodes. ComfyUI Manager → search "EmAySee" → install, restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
No dependencies, no models. Restart and you'll see the pack's "SPECTRE v5.0" banner.
The honest take
It's a focused little tool and it's genuinely useful once you adopt a filename convention - but the convention is the hard part, not the node. Your filenames have to actually be consistent for this to work, and a single non-conforming name silently falls through to fallback_value. The five-slot mapping table is enough for most attribute sets (age, pose, style), but if you need more codes, you'll either chain two of these or move to a lookup file. The defaults (01→teen, 02→young adult, 03→woman) are clearly the author's own tagging scheme - replace them with yours before first use.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| filename | STRING | — | |
| separator | STRING | _ | — |
| target_index | INT | 10–10 | — |
| map_1_code | STRING | 01 | — |
| map_1_value | STRING | teen | — |
| map_2_code | STRING | 02 | — |
| map_2_value | STRING | young adult | — |
| map_3_code | STRING | 03 | — |
| map_3_value | STRING | woman | — |
| map_4_code | STRING | — | |
| map_4_value | STRING | — | |
| map_5_code | STRING | — | |
| map_5_value | STRING | — | |
| fallback_value | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| trigger | STRING | — |